Package org.biojava.utils
Class ChangeType
java.lang.Object
org.biojava.utils.ChangeType
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ChangeType
Constant ChangeType field which indicates that a change has occured which can't otherwise be represented. -
Constructor Summary
ConstructorsConstructorDescriptionChangeType
(String name, Class clazz, String fname) Construct a new ChangeType with supertype UNKNOWN.ChangeType
(String name, Class clazz, String fname, ChangeType superType) Construct a new ChangeType.ChangeType
(String name, Field ourField) Construct a new ChangeType with superType UNKNOWN.ChangeType
(String name, Field ourField, ChangeType superType) Construct a new ChangeType.ChangeType
(String name, String className, String fieldName) ChangeType
(String name, String className, String fieldName, ChangeType superType) -
Method Summary
Modifier and TypeMethodDescriptionstatic Set
getChangeTypes
(Class clazz) Get all ChangeType objects defined within a class.getField()
Return a Field object where this change type is declared.getName()
Return the name of this change.boolean
Returntrue
iffct
is equal to this type or any of it's supertypes (including ChangeType.UNKNOWN).Return an iterator which contains this type, and all supertypes.toString()
Return a string representation of this change.
-
Field Details
-
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 Details
-
ChangeType
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
Construct a new ChangeType with superType UNKNOWN.- Parameters:
name
- The name of this change.ourField
- The public static field which contains this ChangeType.
-
ChangeType
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 inclazz
which is to contain a reference to this change.- Throws:
BioError
- If the field cannot be found.
-
ChangeType
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 inclazz
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
-
ChangeType
-
-
Method Details
-
getName
Return the name of this change.- Returns:
- The Name value
-
getField
Return a Field object where this change type is declared. -
toString
Return a string representation of this change. -
getChangeTypes
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
Return an iterator which contains this type, and all supertypes.- Since:
- 1.2
-
isMatchingType
Returntrue
iffct
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
-