public static class PropertyConstraint.Enumeration extends Object implements PropertyConstraint
Enumeration
accepts a property if it is present
in the specified set of values.
If you want to declare that a property must be within a range
of values, for example PRIMARY_COLOR is one of "RED, YELLOW, BLUE"
Use with FilterUtils.byAnnotation() to search for features
with properties set to a range of valuesPropertyConstraint.And, PropertyConstraint.ByAnnotationType, PropertyConstraint.ByClass, PropertyConstraint.Enumeration, PropertyConstraint.ExactValue, PropertyConstraint.Or
ANY, NONE
Constructor and Description |
---|
PropertyConstraint.Enumeration(Object[] values)
Creates a new
Enumeration using the elements of the
specified array as a constraint. |
PropertyConstraint.Enumeration(Set values)
Creates a new
Enumeration using the members of
the specified set as a constraint. |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Object value)
accept returns true if the value fulfills the
constraint. |
Set |
getValues()
getValues returns the set of values which
constrain the property. |
boolean |
subConstraintOf(PropertyConstraint subConstraint)
subConstraintOf returns true if the constraint
is a sub-constraint. |
String |
toString() |
public PropertyConstraint.Enumeration(Set values)
Enumeration
using the members of
the specified set as a constraint.values
- a Set
of all possible valuespublic PropertyConstraint.Enumeration(Object[] values)
Enumeration
using the elements of the
specified array as a constraint.values
- an Array
of all possible valuespublic Set getValues()
getValues
returns the set of values which
constrain the property.Set
.public boolean accept(Object value)
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 AnnotatoinTypeaccept
in interface PropertyConstraint
value
- an Object
to check.boolean
.public boolean subConstraintOf(PropertyConstraint subConstraint)
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.
subConstraintOf
in interface PropertyConstraint
subConstraint
- a PropertyConstraint
to check.boolean
.Copyright © 2014 BioJava. All rights reserved.