public static class CollectionConstraint.Contains extends Object implements CollectionConstraint
PropertyConstraint is in the supplied cardinality.
A typical application for this would be with Annotations where
one property can contain a number of synonyms.
CollectionConstraint.Contains could be used as
a query to select instances based on one of these synonyms.
CollectionConstraint.AllValuesIn, CollectionConstraint.And, CollectionConstraint.Contains, CollectionConstraint.OrANY, EMPTY, NONE| Constructor and Description |
|---|
Contains(PropertyConstraint pc,
Location card)
Create a Contains based upon a PropertyConstraint and a
cardinality.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Object o)
accept returns true if the value fulfills the
constraint. |
boolean |
equals(Object o) |
Location |
getCardinalityConstraint()
Get the cardinality constraint used to validate the number of property
values.
|
PropertyConstraint |
getPropertyConstraint()
Get the PropertyConstraint used to validate each property value.
|
int |
hashCode() |
boolean |
subConstraintOf(CollectionConstraint cc)
subConstraintOf returns true if the constraint
is a sub-constraint. |
String |
toString() |
boolean |
validateAddValue(Collection oldCol,
Object newValue)
Return
true iff the Collection formed by adding
newValue to current would be accepted
by this constraint. |
boolean |
validateRemoveValue(Collection oldCol,
Object newValue)
Return
true iff the Collection formed by removing
newValue from current would be accepted
by this constraint. |
public Contains(PropertyConstraint pc, Location card)
pc - the PropertyConstraint to apply to each property valuecard - the cardinality constraint restricting the number of
valuespublic PropertyConstraint getPropertyConstraint()
public Location getCardinalityConstraint()
public boolean accept(Object o)
CollectionConstraintaccept returns true if the value fulfills the
constraint.accept in interface CollectionConstrainto - a Collection to check.public boolean validateAddValue(Collection oldCol, Object newValue)
CollectionConstrainttrue iff the Collection formed by adding
newValue to current would be accepted
by this constraint.
Implementations may not assume that current
is valid.validateAddValue in interface CollectionConstraintoldCol - a Collection containing the current valuesnewValue - the new value to addpublic boolean validateRemoveValue(Collection oldCol, Object newValue)
CollectionConstrainttrue iff the Collection formed by removing
newValue from current would be accepted
by this constraint.
Implementations may not assume that current
is valid. However, current will already have been
checked to ensure that it contains victim.validateRemoveValue in interface CollectionConstraintoldCol - a Collection containing the current valuesnewValue - the value to removepublic boolean subConstraintOf(CollectionConstraint cc)
CollectionConstraintsubConstraintOf 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,
CollectionConstraint.ByClass will infer
subConstraintOf by looking at the possible class of all items
matching subConstraint.
subConstraintOf in interface CollectionConstraintcc - a CollectionConstraint to check.boolean.
Usefull 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.Copyright © 2020 BioJava. All rights reserved.