org.biojava.bio
Class PropertyConstraint.ByAnnotationType

java.lang.Object
  extended by org.biojava.bio.PropertyConstraint.ByAnnotationType
All Implemented Interfaces:
PropertyConstraint
Enclosing interface:
PropertyConstraint

public static class PropertyConstraint.ByAnnotationType
extends java.lang.Object
implements PropertyConstraint

ByAnnotationType accepts a property value if it belongs to type defined by AnnotationType.

If you had an Embl AnnotationType then you could say that the REF property must contain annotations that fits your reference AnnotationType (with author list, title, optinal medline ID etc.).

If you wish to build a tree of Annotations so that a property in one is guaranteed to be itself an Annotation of a particular type. Effectively this lets you build your own type system using AnnotationType and PropertyConstraint.

Since:
1.3
Author:
Matthew Pocock

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.bio.PropertyConstraint
PropertyConstraint.And, PropertyConstraint.ByAnnotationType, PropertyConstraint.ByClass, PropertyConstraint.Enumeration, PropertyConstraint.ExactValue, PropertyConstraint.Or
 
Field Summary
 
Fields inherited from interface org.biojava.bio.PropertyConstraint
ANY, NONE
 
Constructor Summary
PropertyConstraint.ByAnnotationType(AnnotationType annType)
          Create a new constraint by type.
 
Method Summary
 boolean accept(java.lang.Object value)
          accept returns true if the value fulfills the constraint.
 AnnotationType getAnnotationType()
          Get the AnnotationType used as a constraint.
 boolean subConstraintOf(PropertyConstraint subConstraint)
          subConstraintOf returns true if the constraint is a sub-constraint.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyConstraint.ByAnnotationType

public PropertyConstraint.ByAnnotationType(AnnotationType annType)
Create a new constraint by type.

Parameters:
annType - the AnnotationType to constrain to
Method Detail

getAnnotationType

public AnnotationType getAnnotationType()
Get the AnnotationType used as a constraint.

Returns:
the AnnotationType constraint

accept

public boolean accept(java.lang.Object value)
Description copied from interface: PropertyConstraint
accept returns true if the value fulfills the constraint. Manually compare items with the PropertyConstraint. Node: this will ususaly be done for you in an AnnotationType instance Use for implementing accept() on AnnotatoinType

Specified by:
accept in interface PropertyConstraint
Parameters:
value - an Object to check.
Returns:
a boolean.

subConstraintOf

public boolean subConstraintOf(PropertyConstraint subConstraint)
Description copied from interface: PropertyConstraint

subConstraintOf returns true if the constraint is a sub-constraint.

A pair of constraints super and sub are in a superConstraint/subConstraint relationship if every object accepted by sub is also accepted by super. To put it another way, if instanceOf was used as a set-membership indicator function over some set of objects, then the set produced by super would be a superset of that produced by sub.

It is not expected that constraints will neccesarily maintain references to super/sub types. It will be more usual to infer this relationship by introspecting the constraints themselves. For example, PropertyConstraint.ByClass will infer subConstraintOf by looking at the possible class of all items matching subConstraint.

Useful when attempting to compare two constraints to see if it is necisary to retain both. You may want to check the more general or the more specific constraint only.

Specified by:
subConstraintOf in interface PropertyConstraint
Parameters:
subConstraint - a PropertyConstraint to check.
Returns:
a boolean.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object