lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Male (JIRA)" <>
Subject [jira] [Commented] (LUCENE-4126) Remove FieldType copy constructor
Date Sat, 09 Jun 2012 14:09:43 GMT


Chris Male commented on LUCENE-4126:

Good question.  

Currently specifying your own FieldType means you have to use {{Field}} rather than {{StringField}}
or {{TextField}} as neither of them accept a FieldType.  This is messy and basically the same
problem that LUCENE-4101 is fixing for storing.  Hmm..

In relation to the the copy constructor issue, for scenario #1 currently users could do:

FieldType myNewFieldType = new FieldType(TextField.TYPE_STORED);

With the copy constructor removed, they would need to do:

FieldType myNewFieldType = new FieldType();
... // set other properties

In the current case the user can easily rely on the pre-existing type and just change the
property they're interested in.  In their code it would be clear what was changed since no
other properties need to be set.  At the same time any changes to the pre-existing type would
flow into their type without them being notified and they cannot scan over their code and
see exactly what properties are set for a field, they'd have to look up the definition.

With the copy constructor removed, we make changing a property more of a task for the user
since they would need to define all the properties themselves.  Yet at the same time they
would be protected from any changes to pre-existing types and they could see in their code
exactly what properties were set.  But it also wouldn't be so easily to see which property
was specifying changed.

I'm not really sure what's best, what do you think?
> Remove FieldType copy constructor
> ---------------------------------
>                 Key: LUCENE-4126
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Chris Male
>             Fix For: 4.0, 5.0
> Currently FieldTypes can be created using new FieldType(someOtherFieldType) which copies
the properties and allows them to then changed.  This reduces readability since it hides what
properties someOtherFieldType has enabled.  We should encourage users (and ourselves) to explicitly
state what properties are enabled so to prevent any surprises. 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message