Class AnnotationConstraint
- java.lang.Object
-
- org.onosproject.net.intent.constraint.BooleanConstraint
-
- org.onosproject.net.intent.constraint.AnnotationConstraint
-
- All Implemented Interfaces:
Constraint
@Beta public class AnnotationConstraint extends BooleanConstraint
Constraint that evaluates an arbitrary link annotated value is under the specified threshold.
-
-
Constructor Summary
Constructors Constructor Description AnnotationConstraint(java.lang.String key, double threshold)
Creates a new constraint to keep the value for the specified key of link annotation under the threshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
cost(Link link, ResourceContext context)
Evaluates the specified link and provides the cost for its traversal.boolean
equals(java.lang.Object obj)
int
hashCode()
boolean
isValid(Link link, ResourceContext context)
Returns true if the specified link satisfies the constraint.java.lang.String
key()
Returns the key of link annotation this constraint designates.double
threshold()
Returns the threshold this constraint ensures as link annotated value.java.lang.String
toString()
-
Methods inherited from class org.onosproject.net.intent.constraint.BooleanConstraint
validate
-
-
-
-
Constructor Detail
-
AnnotationConstraint
public AnnotationConstraint(java.lang.String key, double threshold)
Creates a new constraint to keep the value for the specified key of link annotation under the threshold.- Parameters:
key
- key of link annotationthreshold
- threshold value of the specified link annotation
-
-
Method Detail
-
key
public java.lang.String key()
Returns the key of link annotation this constraint designates.- Returns:
- key of link annotation
-
threshold
public double threshold()
Returns the threshold this constraint ensures as link annotated value.- Returns:
- threshold as link annotated value
-
isValid
public boolean isValid(Link link, ResourceContext context)
Description copied from class:BooleanConstraint
Returns true if the specified link satisfies the constraint.- Specified by:
isValid
in classBooleanConstraint
- Parameters:
link
- link to be validatedcontext
- resource context for checking available resources- Returns:
- true if link is viable
-
cost
public double cost(Link link, ResourceContext context)
Description copied from class:BooleanConstraint
Evaluates the specified link and provides the cost for its traversal. Negative return value means the specified link does not satisfy this constraint.- Specified by:
cost
in interfaceConstraint
- Overrides:
cost
in classBooleanConstraint
- Parameters:
link
- link to be evaluatedcontext
- resource context for validating availability of resources- Returns:
- cost of link traversal
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-