Class AbstractResourceConstraint
java.lang.Object
com.dna.jopt.member.unit.condition.resource.AbstractResourceConstraint
- All Implemented Interfaces:
IConstraint
,IConstraintResource
,Serializable
- Direct Known Subclasses:
BindingResourceConstraint
,ExcludingResourceConstraint
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addResource
(String resId, int priority) Checks whether theresId
is notnull
orempty
and thepriority
is not below or equal0
, then sets themaxPriority
topriority
.boolean
addResources
(List<String> ressIds, List<Integer> priorities) Checks if neither theressIds
nor thepriorities
arenull
orempty
and that they are the same size, then adds a resourceaddResource(String, int)
for everyressIds
.int
Gets themaxPriority
.int
getPriority
(String resId) Gets the priority of the resource id.Gets an ArrayList of the resource ids.boolean
boolean
isHard()
Checks the parameter or directly returnstrue
where this must be the case.void
removeResource
(String resId) If theResource
that is to be removed does not have themaxPriority
, it is removed.void
setIsHard
(boolean isHard) Sets the constraint tohard
if the respective parameter is given or returns anIllegalStateException
if this is expected but not the case.void
setMaxPriority
(int maxPriority) void
setResPriorityMap
(Map<String, Integer> resPriorityMap) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.dna.jopt.member.unit.condition.IConstraint
assessConstraint, getTitle, isSatisfied
-
Constructor Details
-
AbstractResourceConstraint
public AbstractResourceConstraint()
-
-
Method Details
-
isHard
public boolean isHard()Description copied from interface:IConstraint
Checks the parameter or directly returnstrue
where this must be the case.- Specified by:
isHard
in interfaceIConstraint
- Returns:
- the value of the checked boolean
-
setIsHard
public void setIsHard(boolean isHard) Description copied from interface:IConstraint
Sets the constraint tohard
if the respective parameter is given or returns anIllegalStateException
if this is expected but not the case.- Specified by:
setIsHard
in interfaceIConstraint
- Parameters:
isHard
- the boolean to be set
-
addResource
Description copied from interface:IConstraintResource
Checks whether theresId
is notnull
orempty
and thepriority
is not below or equal0
, then sets themaxPriority
topriority
.- Specified by:
addResource
in interfaceIConstraintResource
- Parameters:
resId
- the string resource idpriority
- the int priority- Returns:
- true, if was added
-
addResources
Description copied from interface:IConstraintResource
Checks if neither theressIds
nor thepriorities
arenull
orempty
and that they are the same size, then adds a resourceaddResource(String, int)
for everyressIds
.- Specified by:
addResources
in interfaceIConstraintResource
- Parameters:
ressIds
- the list of string idspriorities
- the list of integer priorities- Returns:
- true, if all were added
-
removeResource
Description copied from interface:IConstraintResource
If theResource
that is to be removed does not have themaxPriority
, it is removed.Otherwise, the
priority
of theResource
is set to0
and themaxPriority
is set to thepriority
of one of the remainingResources
. Then theResource
with the givenresId
is removed.- Specified by:
removeResource
in interfaceIConstraintResource
- Parameters:
resId
- the string id of the resource to be removed
-
getResourceIds
Description copied from interface:IConstraintResource
Gets an ArrayList of the resource ids.- Specified by:
getResourceIds
in interfaceIConstraintResource
- Returns:
- an arrayList with a set view of the keys contained in this map
-
getPriority
Description copied from interface:IConstraintResource
Gets the priority of the resource id.- Specified by:
getPriority
in interfaceIConstraintResource
- Parameters:
resId
- string of the resource id- Returns:
- the priority of the resource
-
getMaxPriority
public int getMaxPriority()Description copied from interface:IConstraintResource
Gets themaxPriority
.- Specified by:
getMaxPriority
in interfaceIConstraintResource
- Returns:
- the max priority
-
setMaxPriority
public void setMaxPriority(int maxPriority) -
hasMembers
public boolean hasMembers()- Specified by:
hasMembers
in interfaceIConstraint
-
getResPriorityMap
- Specified by:
getResPriorityMap
in interfaceIConstraintResource
-
setResPriorityMap
-