|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.bio.AnnotationTools
public final class AnnotationTools
AnnotationTools
is a set of static utility methods for
manipulating Annotation
s and AnnotationType
s.
The methods allIn() and allOut() let you compare an Annotation to an AnnotationType and produce a new Annotation with only those properties explicitly constrained by or not constrained by the type. This could be of use when using an Annotation as a template for some object. You could use allOut to make an Annotation that has all the properties that do not fit into normal constructor properties, and pass that in as the Annotation bundle.
intersection(AnnotationType) and union(AnnotationType) return new AnnotationType instances that will accept every Annotation instance that is accepted by both or either respectively. It is particularly informative to compare the result of this to the AnnotationType.NONE to see if the two types are mutualy disjoint.
intersection(PropertyConstraint) and union(PropertyConstraint) return new PropertyConstraint instances that will accept every Object that is accepted by both or either one respectively.
Constructor Summary | |
---|---|
AnnotationTools()
|
Method Summary | |
---|---|
static Annotation |
allIn(Annotation annotation,
AnnotationType annType)
Destructive down-cast an annotation to a type. |
static Annotation |
allOut(Annotation annotation,
AnnotationType annType)
allOut returns a new Annotation
containing only those values in the Annotation
argument which are not of a type specified by
the AnnotationType . |
static AnnotationType |
intersection(AnnotationType ann1,
AnnotationType ann2)
Calculate an AnnotationType that matches all Annotation instances matched by both types. |
static CollectionConstraint |
intersection(CollectionConstraint cc1,
CollectionConstraint cc2)
Return the CollectionConstraint which accept only collections accepted by both of those specified. |
static PropertyConstraint |
intersection(PropertyConstraint pc1,
PropertyConstraint pc2)
Calculate the intersection of two PropertyConstraint instances. |
static Set |
searchAnnotation(Annotation ann,
AnnotationType query)
Scans an Annotation with an AnnotationType and returns all Annotation instances matching a Type. |
static AnnotationType |
union(AnnotationType ann1,
AnnotationType ann2)
Create an AnnotationType that matches all Anntotations that are accepted by two others. |
static CollectionConstraint |
union(CollectionConstraint cc1,
CollectionConstraint cc2)
Calculate a CollectionConstaint that will accept all items accepted by either constraint. |
static PropertyConstraint |
union(PropertyConstraint pc1,
PropertyConstraint pc2)
Create a PropertyConstraint that matches all Objects that are accepted by two others. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationTools()
Method Detail |
---|
public static Annotation allIn(Annotation annotation, AnnotationType annType)
Destructive down-cast an annotation to a type.
allIn
returns a new Annotation
containing only those values in the Annotation
argument which are of a type specified by the
AnnotationType
.
annotation
- an Annotation
to scan.annType
- an AnnotationType
.
Annotation
.public static Annotation allOut(Annotation annotation, AnnotationType annType)
allOut
returns a new Annotation
containing only those values in the Annotation
argument which are not of a type specified by
the AnnotationType
.
annotation
- an Annotation
.annType
- an AnnotationType
.
Annotation
value.public static Set searchAnnotation(Annotation ann, AnnotationType query)
Scans an Annotation with an AnnotationType and returns all Annotation instances matching a Type.
This differs from AnnotationType.instanceOf() as it will descend into properties of an Annotation if that property is itself an Annotation. This allows you to scan a tree of Annotations for nodes in the tree of a particular shape.
ann
- the Annotation to scanquery
- the AnnotationType to match against all nodes in the tree
public static AnnotationType intersection(AnnotationType ann1, AnnotationType ann2)
ann1
- the first AnnotationTypeann2
- the seccond AnnotationType
public static PropertyConstraint intersection(PropertyConstraint pc1, PropertyConstraint pc2)
pc1
- the first PropertyConstraintpc2
- the seccond PropertyConstraint
public static AnnotationType union(AnnotationType ann1, AnnotationType ann2)
ann1
- the first AnnotationTypeann2
- the seccond AnnotationType
public static PropertyConstraint union(PropertyConstraint pc1, PropertyConstraint pc2)
pc1
- the first PropertyConstraintpc2
- the second PropertyConstraint
public static CollectionConstraint intersection(CollectionConstraint cc1, CollectionConstraint cc2)
cc1
- the first CollectionConstraintcc2
- the seccond CollectionConstrant
public static CollectionConstraint union(CollectionConstraint cc1, CollectionConstraint cc2)
cc1
- the first CollectionConstraintcc2
- the seccond collectionConstraint
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |