org.biojava.bio
Class PropertyConstraint.ExactValue

java.lang.Object
  extended byorg.biojava.bio.PropertyConstraint.ExactValue
All Implemented Interfaces:
PropertyConstraint
Enclosing class:
PropertyConstraint

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

Matches properties if they have exactly this one value.

This is like the extreme case of an Enumeration which has just one member. It is most usefull for selecting annotations with a particular property set to a particular value e.g. ID="01234".

Author:
Matthew Pocock
For general use:
If you want to declare that a property must have a single value
For advanced users:
In conjunction with CardinalityConstraint.ZERO_OR_ONE you could make a property that is potional but if present must have this value

Use with FilterUtils.byAnnotation() to search for features with properties set to specific values

Nested Class Summary
 
Nested classes inherited from class 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.ExactValue(java.lang.Object value)
          Get a PropertyConstraint that matches this object and all those that are equal to it (by the Object.equals() method).
 
Method Summary
 boolean accept(java.lang.Object obj)
          accept returns true if the value fulfills the constraint.
 java.lang.Object getValue()
           
 boolean subConstraintOf(PropertyConstraint pc)
          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.ExactValue

public PropertyConstraint.ExactValue(java.lang.Object value)
Get a PropertyConstraint that matches this object and all those that are equal to it (by the Object.equals() method).

Parameters:
value - the Object to match against
For general use:
Method Detail

getValue

public java.lang.Object getValue()

accept

public boolean accept(java.lang.Object obj)
Description copied from interface: PropertyConstraint
accept returns true if the value fulfills the constraint.

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

subConstraintOf

public boolean subConstraintOf(PropertyConstraint pc)
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.

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

toString

public java.lang.String toString()