[ 
https://issues.apache.org/jira/browse/LUCENE-1998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12768304#action_12768304
 ] 

DM Smith commented on LUCENE-1998:
----------------------------------

bq. changing the order of enum constants is bad, you should always add them at 
the end
Is this true?

I did not know how Java serializes enums so I went looking:
See: http://java.sun.com/j2se/1.5.0/docs/guide/serialization/relnotes15.html

Turns out it serializes the text representation of the enum constant and class 
info. This is just like the Parameter class.

If I understand it correctly, with this, an enum is resilient to changes in 
order. New constants can go in any place (for example, we can later add 
LUCENE_291 before LUCENE_30) and not break serialization compatibility.

This is especially good for the future as it allows a path for deprecations. 
(E.g. deprecation of o.a.l.d.Field.Index.COMPRESS)

So having LUCENE_CURRENT at the end is fine.

If we wanted it first (or anywhere else) we could have onOrAfter to be:
public boolean onOrAfter(Version other) { return other == LUCENE_CURRENT || 
compareTo(other) >= 0; }

If we wanted to expose version numbering info in the future, I'd suggest the 
following pattern (names are unimportant):
LUCENE_29 {
   public int getMajor() { return 2; }
   public int getMinor() { return 9; }
   public int getFix()      { return 0; }
}
because it does not require storage and unlike "2900" does not have positional 
notation meaning (PIC code), e.g. public int getMajor() { return 
int(2900/1000); }

> Use Java 5 enums
> ----------------
>
>                 Key: LUCENE-1998
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1998
>             Project: Lucene - Java
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: DM Smith
>            Assignee: Uwe Schindler
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: LUCENE-1998_enum.patch, LUCENE-1998_enum.patch, 
> LUCENE-1998_enum.patch, LUCENE-1998_enum.patch
>
>
> Replace the use of o.a.l.util.Parameter with Java 5 enums, deprecating 
> Parameter.
> Replace other custom enum patterns with Java 5 enums.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to