Class ChangeType

  • All Implemented Interfaces:
    java.io.Serializable

    public final class ChangeType
    extends java.lang.Object
    implements java.io.Serializable
    Class for all constants which are used to indicate change types. Note that all ChangeType objects must be accessible via a public static field of some class or interface. These should be specified at construction time, so that the ChangeType can be properly serialized. Typically, they should be constructed using code like:
     class MyClassWhichCanFireChangeEvents {
       public final static ChangeType CHANGE_COLOR = new ChangeType(
                  "Color change",
                  MyClassWhichCanFireChangeEvents.class,
                  "CHANGE_COLOR");
       // Rest of the class here...
     }
     

    As of BioJava 1.2, the known ChangeTypes of a system follow a simple hierarchy with single inheritance. All ChangeTypes (except ChangeType.UNKNOWN) have a parent ChangeType (defaulting to ChangeType.UNKNOWN). Generally, when a listener is registered for changetype foo, changes of type bar should be accepted if bar is a sub-type of foo. This can be checked using an expression like:

         bar.isMatchingType(foo);
     
    Since:
    1.1
    Author:
    Thomas Down, Matthew Pocock
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ChangeType UNKNOWN
      Constant ChangeType field which indicates that a change has occured which can't otherwise be represented.
    • Constructor Summary

      Constructors 
      Constructor Description
      ChangeType​(java.lang.String name, java.lang.Class clazz, java.lang.String fname)
      Construct a new ChangeType with supertype UNKNOWN.
      ChangeType​(java.lang.String name, java.lang.Class clazz, java.lang.String fname, ChangeType superType)
      Construct a new ChangeType.
      ChangeType​(java.lang.String name, java.lang.reflect.Field ourField)
      Construct a new ChangeType with superType UNKNOWN.
      ChangeType​(java.lang.String name, java.lang.reflect.Field ourField, ChangeType superType)
      Construct a new ChangeType.
      ChangeType​(java.lang.String name, java.lang.String className, java.lang.String fieldName)  
      ChangeType​(java.lang.String name, java.lang.String className, java.lang.String fieldName, ChangeType superType)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Set getChangeTypes​(java.lang.Class clazz)
      Get all ChangeType objects defined within a class.
      java.lang.reflect.Field getField()
      Return a Field object where this change type is declared.
      java.lang.String getName()
      Return the name of this change.
      boolean isMatchingType​(ChangeType ct)
      Return true iff ct is equal to this type or any of it's supertypes (including ChangeType.UNKNOWN).
      java.util.Iterator matchingTypes()
      Return an iterator which contains this type, and all supertypes.
      java.lang.String toString()
      Return a string representation of this change.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • UNKNOWN

        public static final ChangeType UNKNOWN
        Constant ChangeType field which indicates that a change has occured which can't otherwise be represented. Please do not use this when there is another, more sensible, option. This is the fallback for when you realy don't know what else to do.

        As of BioJava 1.2, this type is the root of the ChangeType hierarchy. Listening for this type is equivalent to listening for all ChangeTypes.

    • Constructor Detail

      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.reflect.Field ourField,
                          ChangeType superType)
        Construct a new ChangeType.
        Parameters:
        name - The name of this change.
        ourField - The public static field which contains this ChangeType.
        superType - The supertype of this type.
        Since:
        1.2
      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.reflect.Field ourField)
        Construct a new ChangeType with superType UNKNOWN.
        Parameters:
        name - The name of this change.
        ourField - The public static field which contains this ChangeType.
      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.Class clazz,
                          java.lang.String fname)
        Construct a new ChangeType with supertype UNKNOWN.
        Parameters:
        name - The name of this change.
        clazz - The class which is going to contain this change.
        fname - The name of the field in clazz which is to contain a reference to this change.
        Throws:
        BioError - If the field cannot be found.
      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.Class clazz,
                          java.lang.String fname,
                          ChangeType superType)
        Construct a new ChangeType.
        Parameters:
        name - The name of this change.
        clazz - The class which is going to contain this change.
        fname - The name of the field in clazz which is to contain a reference to this change.
        superType - the supertype of this type.
        Throws:
        BioError - If the field cannot be found.
        Since:
        1.2
      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.String className,
                          java.lang.String fieldName,
                          ChangeType superType)
      • ChangeType

        public ChangeType​(java.lang.String name,
                          java.lang.String className,
                          java.lang.String fieldName)
    • Method Detail

      • getName

        public java.lang.String getName()
        Return the name of this change.
        Returns:
        The Name value
      • getField

        public java.lang.reflect.Field getField()
        Return a Field object where this change type is declared.
      • toString

        public java.lang.String toString()
        Return a string representation of this change.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Description of the Returned Value
      • getChangeTypes

        public static java.util.Set getChangeTypes​(java.lang.Class clazz)
        Get all ChangeType objects defined within a class. This includes ChangeTypes defined in superclasses and interfaces. Only fields declared as public [final] static ChangeType are returned.
        Parameters:
        clazz - A class to introspect
      • matchingTypes

        public java.util.Iterator matchingTypes()
        Return an iterator which contains this type, and all supertypes.
        Since:
        1.2
      • isMatchingType

        public boolean isMatchingType​(ChangeType ct)
        Return true iff ct is equal to this type or any of it's supertypes (including ChangeType.UNKNOWN). If this is true, then ct is more general than this.
        Since:
        1.2