org.biojava.bio
Class PropertyConstraint.ByClass
java.lang.Object
org.biojava.bio.PropertyConstraint.ByClass
- All Implemented Interfaces:
- PropertyConstraint
- Enclosing class:
- PropertyConstraint
- public static class PropertyConstraint.ByClass
- extends java.lang.Object
- implements PropertyConstraint
ByClass
accepts a property value if it is an
instance of a specific Java class.
- Since:
- 1.3
- Author:
- Matthew Pocock
- For general use:
- Constrain a property to containing values of a particular class
e.g.
new ByClass(String.class)
or
new ByClass(Double)
will ensure
that the property is a String or a Double respecitvely.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
PropertyConstraint.ByClass
public PropertyConstraint.ByClass(java.lang.Class cl)
- Create a new ByClass instance.
- Parameters:
cl
- the Class that all properties must be assignable to- For general use:
getPropertyClass
public java.lang.Class getPropertyClass()
accept
public boolean accept(java.lang.Object value)
- Description copied from interface:
PropertyConstraint
accept
returns true if the value fulfills the
constraint.
- 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.
- Specified by:
subConstraintOf
in interface PropertyConstraint
- Parameters:
subConstraint
- a PropertyConstraint
to check.
- Returns:
- a
boolean
.
toString
public java.lang.String toString()