Class 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 Detail

      • AnnotationConstraint

        public AnnotationConstraint​(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 annotation
        threshold - threshold value of the specified link annotation
    • Method Detail

      • key

        public 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 class BooleanConstraint
        Parameters:
        link - link to be validated
        context - 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 interface Constraint
        Overrides:
        cost in class BooleanConstraint
        Parameters:
        link - link to be evaluated
        context - resource context for validating availability of resources
        Returns:
        cost of link traversal
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object