Package org.biojava.bio
Class PropertyConstraint.ByClass
java.lang.Object
org.biojava.bio.PropertyConstraint.ByClass
- All Implemented Interfaces:
PropertyConstraint
- Enclosing interface:
PropertyConstraint
ByClass
accepts a property value if it is an
instance of a specific Java class.- Since:
- 1.3
- Author:
- Matthew Pocock
Constrain a property to containing values of a particular class
e.g.
new ByClass(String.class)
ornew ByClass(Double)
will ensure that the property is a String or a Double respecitvely.
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
returns true if the value fulfills the constraint.Get the Class used as the constraint.boolean
subConstraintOf
(PropertyConstraint subConstraint) subConstraintOf
returns true if the constraint is a sub-constraint.toString()
-
Constructor Details
-
ByClass
Create a new ByClass instance.- Parameters:
cl
- the Class that all properties must be assignable to
-
-
Method Details
-
getPropertyClass
Get the Class used as the constraint.- Returns:
- the Class all properties must be instances of
-
accept
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 interfacePropertyConstraint
- Parameters:
value
- anObject
to check.- Returns:
- a
boolean
.
-
subConstraintOf
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,
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.PropertyConstraint.ByClass
will infer subConstraintOf by looking at the possible class of all items matching subConstraint.- Specified by:
subConstraintOf
in interfacePropertyConstraint
- Parameters:
subConstraint
- aPropertyConstraint
to check.- Returns:
- a
boolean
.
-
toString
-