src/main/java/com/antbrains/wordseg/luceneanalyzer/AttributeImpl.java
public void reflectWith(AttributeReflector reflector) {
    final Class<? extends AttributeImpl> clazz = this.getClass();
    final LinkedList<WeakReference<Class<? extends Attribute>>> interfaces = AttributeSource
        .getAttributeInterfaces(clazz);
    if (interfaces.size() != 1) {
      throw new UnsupportedOperationException(
          clazz.getName()
              + " implements more than one Attribute interface, the default reflectWith() implementation cannot handle this.");
    }
    final Class<? extends Attribute> interf = interfaces.getFirst().get();
    final Field[] fields = clazz.getDeclaredFields();
    try {
      for (int i = 0; i < fields.length; i++) {
        final Field f = fields[i];
        if (Modifier.isStatic(f.getModifiers()))
          continue;
        f.setAccessible(true);
        reflector.reflect(interf, f.getName(), f.get(this));
      }
    } catch (IllegalAccessException e) {
      // this should never happen, because we're just accessing fields
      // from 'this'
      throw new RuntimeException(e);
    }
  }
/**
   * This method is for introspection of attributes, it should simply add the key/values this
   * attribute holds to the given {@link AttributeReflector}.
   *
   * <p>
   * The default implementation calls {@link AttributeReflector#reflect} for all non-static fields
   * from the implementing class, using the field name as key and the field value as value. The
   * Attribute class is also determined by reflection. Please note that the default implementation
   * can only handle single-Attribute implementations.
   *
   * <p>
   * Custom implementations look like this (e.g. for a combined attribute implementation):
   * 
   * <pre>
   * public void reflectWith(AttributeReflector reflector) {
   *   reflector.reflect(CharTermAttribute.class, &quot;term&quot;, term());
   *   reflector.reflect(PositionIncrementAttribute.class, &quot;positionIncrement&quot;, getPositionIncrement());
   * }
   * </pre>
   *
   * <p>
   * If you implement this method, make sure that for each invocation, the same set of
   * {@link Attribute} interfaces and keys are passed to {@link AttributeReflector#reflect} in the
   * same order, but possibly different values. So don't automatically exclude e.g. {@code null}
   * properties!
   *
   * @see #reflectAsString(boolean)
   */
This method is for introspection of attributes, it should simply add the key/values this
attribute holds to the given  AttributeReflector.


The default implementation calls  AttributeReflector#reflect for all non-static fields
from the implementing class, using the field name as key and the field value as value. The
Attribute class is also determined by reflection. Please note that the default implementation
can only handle single-Attribute implementations.


Custom implementations look like this .




If you implement this method, make sure that for each invocation, the same set of
Attribute interfaces and keys are passed to  AttributeReflector#reflect in the
same order, but possibly different values. So don't automatically exclude e.g.  null
properties!


This method is for introspection of attributes it should simply add the key / values this attribute holds to the given AttributeReflector . The default implementation calls AttributeReflector#reflect for all non - static fields from the implementing class using the field name as key and the field value as value . The Attribute class is also determined by reflection . Please note that the default implementation can only handle single - Attribute implementations . Custom implementations look like this . If you implement this method make sure that for each invocation the same set of Attribute interfaces and keys are passed to AttributeReflector#reflect in the same order but possibly different values . So don ' t automatically exclude e . g . null properties!
public void reflectWith(AttributeReflector reflector) {
    final Class<? extends AttributeImpl> clazz = this.getClass();
    final LinkedList<WeakReference<Class<? extends Attribute>>> interfaces = AttributeSource
        .getAttributeInterfaces(clazz);
    if (interfaces.size() != 1) {
      throw new UnsupportedOperationException(
          clazz.getName()
              + " implements more than one Attribute interface, the default reflectWith() implementation cannot handle this.");
    }
    final Class<? extends Attribute> interf = interfaces.getFirst().get();
    final Field[] fields = clazz.getDeclaredFields();
    try {
      for (int i = 0; i < fields.length; i++) {
        final Field f = fields[i];
        if (Modifier.isStatic(f.getModifiers()))
          continue;
        f.setAccessible(true);
        reflector.reflect(interf, f.getName(), f.get(this));
      }
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
public void reflectWith ( AttributeReflector reflector ) { final Class < ? extends AttributeImpl > clazz = this . getClass ( ) ; final LinkedList < WeakReference < Class < ? extends Attribute > > > interfaces = AttributeSource . getAttributeInterfaces ( clazz ) ; if ( interfaces . size ( ) != 1 ) { throw new UnsupportedOperationException ( clazz . getName ( ) + " implements more than one Attribute interface, the default reflectWith() implementation cannot handle this." ) ; } final Class < ? extends Attribute > interf = interfaces . getFirst ( ) . get ( ) ; final Field [ ] fields = clazz . getDeclaredFields ( ) ; try { for ( int i = 0 ; i < fields . length ; i ++ ) { final Field f = fields [ i ] ; if ( Modifier . isStatic ( f . getModifiers ( ) ) ) continue ; f . setAccessible ( true ) ; reflector . reflect ( interf , f . getName ( ) , f . get ( this ) ) ; } } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
This method is for introspection of attributes, it should simply add the key/values this
 attribute holds to the given {@link AttributeReflector}.
This method is for introspection of attributes it should simply add the key / values this attribute holds to the given { @link AttributeReflector } .
// this should never happen, because we're just accessing fields
 // from 'this'
