Package org.biojava.bio
Class PropertyConstraint.Or
- java.lang.Object
-
- org.biojava.bio.PropertyConstraint.Or
-
- All Implemented Interfaces:
PropertyConstraint
- Enclosing interface:
- PropertyConstraint
public static class PropertyConstraint.Or extends Object implements PropertyConstraint
A property constraint that accepts items iff they are accepted by either child constraints. This effectively matches the union of the items matched by the two constraints. Use this to combine multiple constraints. You can make one or both of the children Or instances if you need a wider union.- 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
Constructors Constructor Description Or(PropertyConstraint c1, PropertyConstraint c2)
Create a newOr
from two child constraints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(Object object)
accept
returns true if the value fulfills the constraint.PropertyConstraint
getChild1()
Get the first child PropertyConstraint.PropertyConstraint
getChild2()
Get the seccond child PropertyConstraint.boolean
subConstraintOf(PropertyConstraint pc)
subConstraintOf
returns true if the constraint is a sub-constraint.String
toString()
-
-
-
Constructor Detail
-
Or
public Or(PropertyConstraint c1, PropertyConstraint c2)
Create a newOr
from two child constraints.- Parameters:
c1
- the first childc2
- the seccond child
-
-
Method Detail
-
getChild1
public PropertyConstraint getChild1()
Get the first child PropertyConstraint.- Returns:
- the first child PropertyConstraint
-
getChild2
public PropertyConstraint getChild2()
Get the seccond child PropertyConstraint.- Returns:
- the seccond child PropertyConstraint
-
accept
public boolean accept(Object object)
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:
object
- anObject
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,
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:
pc
- aPropertyConstraint
to check.- Returns:
- a
boolean
.
-
-