Class AbstractResourceConstraint

java.lang.Object
com.dna.jopt.member.unit.condition.resource.AbstractResourceConstraint
All Implemented Interfaces:
IConstraint, IConstraintResource, Serializable
Direct Known Subclasses:
BindingResourceConstraint, ExcludingResourceConstraint

public abstract class AbstractResourceConstraint extends Object implements IConstraintResource
See Also:
  • Constructor Details

    • AbstractResourceConstraint

      public AbstractResourceConstraint()
  • Method Details

    • isHard

      public boolean isHard()
      Description copied from interface: IConstraint
      Checks the parameter or directly returns true where this must be the case.
      Specified by:
      isHard in interface IConstraint
      Returns:
      the value of the checked boolean
    • setIsHard

      public void setIsHard(boolean isHard)
      Description copied from interface: IConstraint
      Sets the constraint to hard if the respective parameter is given or returns an IllegalStateException if this is expected but not the case.
      Specified by:
      setIsHard in interface IConstraint
      Parameters:
      isHard - the boolean to be set
    • addResource

      public boolean addResource(String resId, int priority)
      Description copied from interface: IConstraintResource
      Checks whether the resId is not null or empty and the priority is not below or equal 0, then sets the maxPriority to priority.
      Specified by:
      addResource in interface IConstraintResource
      Parameters:
      resId - the string resource id
      priority - the int priority
      Returns:
      true, if was added
    • addResources

      public boolean addResources(List<String> ressIds, List<Integer> priorities)
      Description copied from interface: IConstraintResource
      Checks if neither the ressIds nor the priorities are null or empty and that they are the same size, then adds a resource addResource(String, int) for every ressIds.
      Specified by:
      addResources in interface IConstraintResource
      Parameters:
      ressIds - the list of string ids
      priorities - the list of integer priorities
      Returns:
      true, if all were added
    • removeResource

      public void removeResource(String resId)
      Description copied from interface: IConstraintResource
      If the Resource that is to be removed does not have the maxPriority, it is removed.

      Otherwise, the priority of the Resource is set to 0 and the maxPriority is set to the priority of one of the remaining Resources. Then the Resource with the given resId is removed.

      Specified by:
      removeResource in interface IConstraintResource
      Parameters:
      resId - the string id of the resource to be removed
    • getResourceIds

      public List<String> getResourceIds()
      Description copied from interface: IConstraintResource
      Gets an ArrayList of the resource ids.
      Specified by:
      getResourceIds in interface IConstraintResource
      Returns:
      an arrayList with a set view of the keys contained in this map
    • getPriority

      public int getPriority(String resId)
      Description copied from interface: IConstraintResource
      Gets the priority of the resource id.
      Specified by:
      getPriority in interface IConstraintResource
      Parameters:
      resId - string of the resource id
      Returns:
      the priority of the resource
    • getMaxPriority

      public int getMaxPriority()
      Description copied from interface: IConstraintResource
      Gets the maxPriority.
      Specified by:
      getMaxPriority in interface IConstraintResource
      Returns:
      the max priority
    • setMaxPriority

      public void setMaxPriority(int maxPriority)
    • hasMembers

      public boolean hasMembers()
      Specified by:
      hasMembers in interface IConstraint
    • getResPriorityMap

      public Map<String,Integer> getResPriorityMap()
      Specified by:
      getResPriorityMap in interface IConstraintResource
    • setResPriorityMap

      public void setResPriorityMap(Map<String,Integer> resPriorityMap)