Class TierConstraint

  • All Implemented Interfaces:
    Constraint

    @Beta
    public class TierConstraint
    extends BooleanConstraint
    Constraint that evaluates links based on their type.
    • Constructor Summary

      Constructors 
      Constructor Description
      TierConstraint​(boolean inclusive, java.lang.Integer... tiers)
      Creates a new constraint for requesting connectivity using or avoiding the specified link tiers.
      TierConstraint​(boolean inclusive, TierConstraint.CostType costType, java.lang.Integer... tiers)
      Creates a new constraint for requesting connectivity using or avoiding the specified link tiers.
    • Constructor Detail

      • TierConstraint

        public TierConstraint​(boolean inclusive,
                              TierConstraint.CostType costType,
                              java.lang.Integer... tiers)
        Creates a new constraint for requesting connectivity using or avoiding the specified link tiers.
        Parameters:
        inclusive - indicates whether the given link tiers are to be permitted or avoided
        costType - defines the model used to calculate the link cost.
        tiers - link tiers
      • TierConstraint

        public TierConstraint​(boolean inclusive,
                              java.lang.Integer... tiers)
        Creates a new constraint for requesting connectivity using or avoiding the specified link tiers. The VALID cost type is used by default.
        Parameters:
        inclusive - indicates whether the given link tiers are to be permitted or avoided
        tiers - link tiers
    • Method Detail

      • 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
      • tiers

        public java.util.List<java.lang.Integer> tiers()
        Returns the set of link tiers.
        Returns:
        set of link tiers
      • isInclusive

        public boolean isInclusive()
        Indicates if the constraint is inclusive or exclusive.
        Returns:
        true if inclusive
      • costType

        public TierConstraint.CostType costType()
        Return the cost model used by this constraint.
        Returns:
        true if inclusive
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object