[
https://issues.apache.org/jira/browse/LUCENE-1835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Uwe Schindler updated LUCENE-1835:
----------------------------------
Description:
The last update of Attribute API using AttributeImpl as implementation oif
Attributes changed the API a little bit. This change leads to the fact, that in
Java 1.5 using generics we are no longer able to add Attributes without
casting. addAttribute and getAttribute should return the Attribute interface
because the implementation of the attribute is not interesting to the caller.
By that in 1.5 using generics, one could add a TermAttribute without casting
using:
{code}
TermAttribute termAtt = addAttribute(TermAttribute.class);
{code}
The signature to do this is:
{code}
public <T extends Attribute> T addAttribute(Class<T>)
{code}
The attached patch applies the mentioned change to the signature (without
generic, only returning Attribute). No other code changes are needed, as
current code always casts the result to the requested interface. I also added
the 1.5 method signature for all these methods to the javadocs.
All tests pass.
was:
The last update of Attribute API using AttributeImpl as implementation oif
Attributes changed the API a little bit. This change leads to the fact, that in
Java 1.5 using generics we are no longer able to add Attributes without
casting. addAttribute and getAttribute should return the Attribute interface
because the implementation of the attribute is not interesting to the caller.
By that in 1.5 using generics, one could add a TermAttribute without casting
using:
{code}
TermAttribute termAtt = addAttribute(TermAttribute.class);
{code}
The signature to do this is:
{code}
public K addAttribute(Class<K extends Attribute>)
{code}
The attached patch applies the mentioned change to the signature (without
generic, only returning Attribute). No other code cahnges are needed, as
current code always casts the result to the requested interface. I also added
the 1.5 method signature for all these methods to the javadocs.
All tests pass.
Lucene Fields: [New, Patch Available] (was: [New])
> Signature changes in AttributeSource for better Generics support of
> AddAttribute/getAttribute
> ---------------------------------------------------------------------------------------------
>
> Key: LUCENE-1835
> URL: https://issues.apache.org/jira/browse/LUCENE-1835
> Project: Lucene - Java
> Issue Type: Task
> Components: Analysis
> Affects Versions: 2.9
> Reporter: Uwe Schindler
> Assignee: Uwe Schindler
> Fix For: 2.9
>
> Attachments: LUCENE-1835.patch, LUCENE-1835.patch
>
>
> The last update of Attribute API using AttributeImpl as implementation oif
> Attributes changed the API a little bit. This change leads to the fact, that
> in Java 1.5 using generics we are no longer able to add Attributes without
> casting. addAttribute and getAttribute should return the Attribute interface
> because the implementation of the attribute is not interesting to the caller.
> By that in 1.5 using generics, one could add a TermAttribute without casting
> using:
> {code}
> TermAttribute termAtt = addAttribute(TermAttribute.class);
> {code}
> The signature to do this is:
> {code}
> public <T extends Attribute> T addAttribute(Class<T>)
> {code}
> The attached patch applies the mentioned change to the signature (without
> generic, only returning Attribute). No other code changes are needed, as
> current code always casts the result to the requested interface. I also added
> the 1.5 method signature for all these methods to the javadocs.
> All tests pass.
--
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: [email protected]
For additional commands, e-mail: [email protected]