[
https://issues.apache.org/jira/browse/LUCENE-3777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207639#comment-13207639
]
Michael McCandless commented on LUCENE-3777:
--------------------------------------------
I agree this is trappy! Especially because these are sugar APIs... which
should especially not be trappy.
bq. I don't know what was the intention to change this in trunk,
This was my fault: I did this under LUCENE-3453... each of our Field impls
(well, Field, NF, DVF) had their own setters to change their value... I
consolidated all of these under Field's APIs, which I agree are trappy.
I think we should just break with 3.x here and change Field.setValue(T x) ->
Field.setTValue(T x).
I prefer sugar classes (new IntField(7), new IntValueField(7)) instead of
static factory methods (NumericField.newIntField(7),
DocValuesField.newIntField(7))...
I'll take a crack at this.
> trapping overloaded ctors/setters in Field/NumericField/DocValuesField
> ----------------------------------------------------------------------
>
> Key: LUCENE-3777
> URL: https://issues.apache.org/jira/browse/LUCENE-3777
> Project: Lucene - Java
> Issue Type: Bug
> Affects Versions: 4.0
> Reporter: Robert Muir
> Priority: Blocker
>
> In trunk, these apis let you easily create a field, but my concern is this:
> {code}
> public NumericField(String name, int value)
> public NumericField(String name, long value)
> ..
> public Field(String name, int value, FieldType type)
> public Field(String name, long value, FieldType type)
> ..
> public void setValue(int value)
> public void setValue(long value)
> ..
> public DocValuesField(String name, int value, DocValues.Type docValueType)
> public DocValuesField(String name, long value, DocValues.Type docValueType)
> {code}
> I really don't like overloaded ctors/setters where the compiler can
> type-promote you,
> I think it makes the apis hard to use.
> Instead for the setters I think we sohuld have setIntValue, setLongValue, ...
> For the ctors, I see two other options:
> # factories like DocValuesField.newIntField()
> # subclasses like IntField
> I don't have any patch for this, but I think we should discuss and fix before
> these apis are released.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]