Package org.biojava.bio
Class CollectionConstraint.AllValuesIn
java.lang.Object
org.biojava.bio.CollectionConstraint.AllValuesIn
- All Implemented Interfaces:
CollectionConstraint
- Enclosing interface:
- CollectionConstraint
CollectionConstraint which validates all members of a Collection.
All members must be vaild according to the supplied
PropertyConstraint, and the total number of
members must be acceptable by the given cardinality constraint.- Author:
- Thomas Down, Matthew Pocock
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.bio.CollectionConstraint
CollectionConstraint.AllValuesIn, CollectionConstraint.And, CollectionConstraint.Contains, CollectionConstraint.Or -
Field Summary
Fields inherited from interface org.biojava.bio.CollectionConstraint
ANY, EMPTY, NONE -
Constructor Summary
ConstructorsConstructorDescriptionAllValuesIn(PropertyConstraint pc, Location card) Create an AllValuesIn based upon a PropertyConstraint and a cardinality. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptreturns true if the value fulfills the constraint.booleanGet the cardinality constraint used to validate the number of property values.Get the PropertyConstraint used to validate each property value.inthashCode()booleansubConstraintOfreturns true if the constraint is a sub-constraint.toString()booleanvalidateAddValue(Collection oldcol, Object newValue) Returntrueiff the Collection formed by addingnewValuetocurrentwould be accepted by this constraint.booleanvalidateRemoveValue(Collection oldcol, Object victim) Returntrueiff the Collection formed by removingnewValuefromcurrentwould be accepted by this constraint.
-
Constructor Details
-
AllValuesIn
Create an AllValuesIn based upon a PropertyConstraint and a cardinality.- Parameters:
pc- the PropertyConstraint to apply to each property valuecard- the cardinality constraint restricting the number of values
-
-
Method Details
-
getPropertyConstraint
Get the PropertyConstraint used to validate each property value.- Returns:
- the PropertyConstraint used
-
getCardinalityConstraint
Get the cardinality constraint used to validate the number of property values.- Returns:
- the cardinality constraint as a Location
-
accept
Description copied from interface:CollectionConstraintacceptreturns true if the value fulfills the constraint.- Specified by:
acceptin interfaceCollectionConstraint- Parameters:
o- aCollectionto check.- Returns:
- true if the values are acceptable powerUser Manually compare items with the CollectionConstraint. Node: this will ususaly be done for you in an AnnotationType instance
-
validateAddValue
Description copied from interface:CollectionConstraintReturntrueiff the Collection formed by addingnewValuetocurrentwould be accepted by this constraint. Implementations may not assume thatcurrentis valid.- Specified by:
validateAddValuein interfaceCollectionConstraint- Parameters:
oldcol- a Collection containing the current valuesnewValue- the new value to add- Returns:
- true if adding the new value will result in an acceptable property
-
validateRemoveValue
Description copied from interface:CollectionConstraintReturntrueiff the Collection formed by removingnewValuefromcurrentwould be accepted by this constraint. Implementations may not assume thatcurrentis valid. However,currentwill already have been checked to ensure that it containsvictim.- Specified by:
validateRemoveValuein interfaceCollectionConstraint- Parameters:
oldcol- a Collection containing the current valuesvictim- the value to remove- Returns:
- true if removing the victim will result in an acceptable property value set
-
hashCode
-
equals
-
subConstraintOf
Description copied from interface:CollectionConstraintsubConstraintOfreturns 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.ByClasswill infer subConstraintOf by looking at the possible class of all items matching subConstraint.- Specified by:
subConstraintOfin interfaceCollectionConstraint- Parameters:
cc- aCollectionConstraintto check.- Returns:
- a
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.
-
toString
-