[jira] Created: (LUCENE-2601) Make getAttribute(Class attClass) Generic

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LUCENE-2601) Make getAttribute(Class attClass) Generic

Michael Gibney (Jira)
Make getAttribute(Class attClass) Generic
-----------------------------------------

                 Key: LUCENE-2601
                 URL: https://issues.apache.org/jira/browse/LUCENE-2601
             Project: Lucene - Java
          Issue Type: Improvement
          Components: Other
    Affects Versions: 3.0.2, 3.0.1, 3.0, 2.9.3, 2.9.2, 2.9.1
            Reporter: wenbin.zhu


org.apache.lucene.util.AttributeSource

current:
public Attribute getAttribute(Class attClass) {
    final Attribute att = (Attribute) this.attributes.get(attClass);
    if (att == null) {
      throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
    }
    return att;
}
sample usage:
TermAttribute termAtt = (TermAttribute)ts.getAttribute(TermAttribute.class)


my improvment:
@SuppressWarnings("unchecked")
        public <T> T getAttribute2(Class<? extends Attribute> attClass) {
    final T att = (T) this.attributes.get(attClass);
    if (att == null) {
      throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
    }
    return att;
 }
sample usage:
TermAttribute termAtt = ts.getAttribute(TermAttribute.class)

--
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (LUCENE-2601) Make getAttribute(Class attClass) Generic

Michael Gibney (Jira)

     [ https://issues.apache.org/jira/browse/LUCENE-2601?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler closed LUCENE-2601.
---------------------------------

         Assignee: Uwe Schindler
    Fix Version/s: 3.0
       Resolution: Fixed

Since Lucene 3.0 this is already using generics. Only Lucene 2.9.x does not use generics, as it is Java 1.4 only.

> Make getAttribute(Class attClass) Generic
> -----------------------------------------
>
>                 Key: LUCENE-2601
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2601
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.9.1, 2.9.2, 2.9.3, 3.0, 3.0.1, 3.0.2
>            Reporter: wenbin.zhu
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>
> org.apache.lucene.util.AttributeSource
> current:
> public Attribute getAttribute(Class attClass) {
>     final Attribute att = (Attribute) this.attributes.get(attClass);
>     if (att == null) {
>       throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
>     }
>     return att;
> }
> sample usage:
> TermAttribute termAtt = (TermAttribute)ts.getAttribute(TermAttribute.class)
> my improvment:
> @SuppressWarnings("unchecked")
> public <T> T getAttribute2(Class<? extends Attribute> attClass) {
>     final T att = (T) this.attributes.get(attClass);
>     if (att == null) {
>       throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
>     }
>     return att;
>  }
> sample usage:
> TermAttribute termAtt = ts.getAttribute(TermAttribute.class)

--
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LUCENE-2601) Make getAttribute(Class attClass) Generic

Michael Gibney (Jira)
In reply to this post by Michael Gibney (Jira)

     [ https://issues.apache.org/jira/browse/LUCENE-2601?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler updated LUCENE-2601:
----------------------------------

    Affects Version/s:     (was: 3.0)
                           (was: 3.0.1)
                           (was: 3.0.2)

> Make getAttribute(Class attClass) Generic
> -----------------------------------------
>
>                 Key: LUCENE-2601
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2601
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.9.1, 2.9.2, 2.9.3
>            Reporter: wenbin.zhu
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>
> org.apache.lucene.util.AttributeSource
> current:
> public Attribute getAttribute(Class attClass) {
>     final Attribute att = (Attribute) this.attributes.get(attClass);
>     if (att == null) {
>       throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
>     }
>     return att;
> }
> sample usage:
> TermAttribute termAtt = (TermAttribute)ts.getAttribute(TermAttribute.class)
> my improvment:
> @SuppressWarnings("unchecked")
> public <T> T getAttribute2(Class<? extends Attribute> attClass) {
>     final T att = (T) this.attributes.get(attClass);
>     if (att == null) {
>       throw new IllegalArgumentException("This AttributeSource does not have the attribute '" + attClass.getName() + "'.");
>     }
>     return att;
>  }
> sample usage:
> TermAttribute termAtt = ts.getAttribute(TermAttribute.class)

--
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: [hidden email]
For additional commands, e-mail: [hidden email]