public interface PropertyConstraint
PropertyConstraint
s describes a constraint applied
to the members of an annotation bundle.
PropertyConstraint
s are usually used in conjunction
with the AnnotationType
interface to describe a class
of annotations by the values of their properties. In this way, you
can generate controlled vocabularies over Java objects.
The constraints accept or reject individual objects. In general, it is not possible to get back a set of all items that would be accepted by a particular constraint.
Instantiate PropertyConstraint classes when populating an AnnotationType instance Implement PropertyContraint to provide meta-data about a new type of object relationship. For example, if there was a data-structure representing an inheritance hierachy, then an implementation of PropertyConstraint could be written that allowed a propertie's value to be constrained to be a child of a particular node in the hierachyModifier and Type | Interface and Description |
---|---|
static class |
PropertyConstraint.And
A property constraint that accpepts items iff they are accepted by both
child constraints.
|
static class |
PropertyConstraint.ByAnnotationType
ByAnnotationType accepts a property value if it
belongs to type defined by AnnotationType. |
static class |
PropertyConstraint.ByClass
ByClass accepts a property value if it is an
instance of a specific Java class. |
static class |
PropertyConstraint.Enumeration
Enumeration accepts a property if it is present
in the specified set of values. |
static class |
PropertyConstraint.ExactValue
Matches properties if they have exactly this one value.
|
static class |
PropertyConstraint.Or
A property constraint that accepts items iff they are accepted by either
child constraints.
|
Modifier and Type | Field and Description |
---|---|
static PropertyConstraint |
ANY
ANY is a constraint which accepts a property for
addition under all conditions. |
static PropertyConstraint |
NONE
NONE is a constraint which accepts no value for a property
under any condition. |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Object value)
accept returns true if the value fulfills the
constraint. |
boolean |
subConstraintOf(PropertyConstraint subConstraint)
subConstraintOf returns true if the constraint
is a sub-constraint. |
static final PropertyConstraint ANY
ANY
is a constraint which accepts a property for
addition under all conditions.
Whenever a PropertyConstraint is needed and you want to allow
any value therestatic final PropertyConstraint NONE
NONE
is a constraint which accepts no value for a property
under any condition.
Whenever a PropertyConstraint is needed and you want to
dissalow all values there e.g. when marking a property as having to be unsetboolean accept(Object value)
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 AnnotatoinTypevalue
- an Object
to check.boolean
.boolean subConstraintOf(PropertyConstraint subConstraint)
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.
subConstraint
- a PropertyConstraint
to check.boolean
.Copyright © 2014 BioJava. All rights reserved.