Class Constraint
- java.lang.Object
-
- com.biomatters.geneious.publicapi.documents.Constraint
-
public abstract class Constraint extends java.lang.Object
The idea of a Constraint is very simple. A constraint is made up of 2 things: -> a Condition (for example, "is greater than") -> an operand (for example "23") Together, these form the Constraint where a "value" must be "greater than 23" Therefore, the Constraint interface has the method 'conformsToConstraint(Object value)' The method will return 'true' if the 'value' passed in obeys the Constraint. For the example constraint above, 'conformsToConstraint(new Integer(20))' returns false while 'conformsToConstraint(new Integer(24))' returns true Constraints can be attached to note fields, restricting the values that a field can take. ATTENTION: This interface must not be implemented by plugins. Use the factory method
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
conformsToConstraint(java.lang.Object value)
Returns true ifvalue
conforms to this constraint, false if not.static java.lang.String
constraintsToString(Constraint[] constraints)
A convenient method to neatly list the Constraints.static Constraint
createConstraint(java.lang.Class type, Condition condition, java.lang.Object operand)
Construct a constraint with the given optionsCondition
getCondition()
static Condition[]
getConstraints(java.lang.Class type)
Returns an array of conditions which are allowed to be used to constrain the given type.static java.lang.String[]
getNiceNames(java.lang.Class type)
Returns an array of user-friendly names for conditions which are allowed to be used to constrain the given type.java.lang.Object
getOperand()
Returns the operand or value of this constraint (eg.java.lang.String
toString()
-
-
-
Field Detail
-
condition
protected Condition condition
-
operand
protected java.lang.Object operand
-
-
Method Detail
-
constraintsToString
public static java.lang.String constraintsToString(Constraint[] constraints)
A convenient method to neatly list the Constraints.- Parameters:
constraints
- an array of Constraints- Returns:
- a String representation of the constraints argument
-
createConstraint
public static Constraint createConstraint(java.lang.Class type, Condition condition, java.lang.Object operand)
Construct a constraint with the given options- Parameters:
type
- class of the value which this constraint acts on.condition
- eg. "is greater than"operand
- eg. 20- Returns:
- a constraint with the given options
-
getConstraints
public static Condition[] getConstraints(java.lang.Class type)
Returns an array of conditions which are allowed to be used to constrain the given type.- Parameters:
type
- javaClass
of value to be constrained- Returns:
- an array of conditions which are allowed to be used to constrain the given type
-
getNiceNames
public static java.lang.String[] getNiceNames(java.lang.Class type)
Returns an array of user-friendly names for conditions which are allowed to be used to constrain the given type. Indices are the same as those returned fromgetConstraints(Class)
.- Parameters:
type
- javaClass
of value to be constrained- Returns:
- an array of names for conditions which are allowed to be used to constrain the given type
-
conformsToConstraint
public abstract boolean conformsToConstraint(java.lang.Object value)
Returns true ifvalue
conforms to this constraint, false if not.- Parameters:
value
- to test for conformity- Returns:
- true if
value
conforms to this constraint
-
getCondition
public Condition getCondition()
- Returns:
- the condition (eg. "is greater than") of this constraint
-
getOperand
public java.lang.Object getOperand()
Returns the operand or value of this constraint (eg. 20). This could be a number, string or date.- Returns:
- the operand or value of this constraint
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-