Interface PropertyConstraint
- All Known Implementing Classes:
PropertyConstraint.And
,PropertyConstraint.ByAnnotationType
,PropertyConstraint.ByClass
,PropertyConstraint.Enumeration
,PropertyConstraint.ExactValue
,PropertyConstraint.Or
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 hierachy- Since:
- 1.3
- Author:
- Matthew Pocock, Keith James, Thomas Down
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
A property constraint that accpepts items iff they are accepted by both child constraints.static class
ByAnnotationType
accepts a property value if it belongs to type defined by AnnotationType.static class
ByClass
accepts a property value if it is an instance of a specific Java class.static class
Enumeration
accepts a property if it is present in the specified set of values.static class
Matches properties if they have exactly this one value.static class
A property constraint that accepts items iff they are accepted by either child constraints. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyConstraint
ANY
is a constraint which accepts a property for addition under all conditions.static final PropertyConstraint
NONE
is a constraint which accepts no value for a property under any condition. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
returns true if the value fulfills the constraint.boolean
subConstraintOf
(PropertyConstraint subConstraint) subConstraintOf
returns true if the constraint is a sub-constraint.
-
Field Details
-
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 there -
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 unset
-
-
Method Details
-
accept
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- Parameters:
value
- anObject
to check.- Returns:
- a
boolean
.
-
subConstraintOf
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.- Parameters:
subConstraint
- aPropertyConstraint
to check.- Returns:
- a
boolean
.
-