Class TierConstraint

  • All Implemented Interfaces:
    Constraint

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

      • TierConstraint

        public TierConstraint​(boolean inclusive,
                              TierConstraint.CostType costType,
                              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,
                              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 List<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 Object