Package jsl.modeling.elements.entity
Class Request
- java.lang.Object
-
- jsl.modeling.elements.entity.Request
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequest.StateUnallocated - A state representing when no units of a resource have been allocated to the request PartiallyAllocated - A state representing when units of a resource are allocated to the request FullyAllocated - A state representing when all required units of a resource are allocated to the request
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PRIORITYThe default priority associated with Requests
-
Constructor Summary
Constructors Constructor Description Request()Creates a single unit request Note: the request is not ready until it has been used within a resource.Request(int amtRequested)Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource.Request(int amtRequested, int priority)Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource.Request(int amtRequested, int priority, boolean allowPartialFilling)Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowsPartialFilling()Indicates that the request allows the amount requested to be partially filledintcompareTo(Request req)Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.intgetAmountAllocated()Gets the amount allocated by the resource to the requestintgetAmountNeeded()Returns the amount needed by the requestintgetArrivalNumber()EntitygetEntity()The Entity associated with the requestintgetInitialAmountRequested()Gets the original amount requested.intgetPriority()Gets the priority associated with the requestjava.lang.StringgetResourceSaveKey()ResourceSelectionRuleIfcgetResourceSelectionRule()ResourcegetSeizedResource()Gets the resource that the request is usingResourceSetgetSeizedResourceSet()If the request was made on a ResourceSet then this returns the relevent set (or null)booleanhasResourceAllocationListener()booleanisPartiallyAllocated()Indicates whether the request has been partially allocated to a resourcebooleanisSatisfied()Indicates whether or not the request has been allocated its full amount, i.e.booleanisUnallocated()Indicates whether the request has not been allocated any units from a resourcevoidnullify()Sets all internal references to null.voidsetResourceAllocationListener(AllocationListenerIfc listener)voidsetResourceReleaseListener(ResourceReleaseListenerIfc releaseListener)A ResourceReleaseListener can be attached to the request and provide behavior right after the request has release units of a resource.voidsetResourceSelectionRule(ResourceSelectionRuleIfc rule)java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
The default priority associated with Requests- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Request
public Request()
Creates a single unit request Note: the request is not ready until it has been used within a resource. No partial filling Default seize priority
-
Request
public Request(int amtRequested)
Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource. No partial filling Default seize priority- Parameters:
amtRequested-
-
Request
public Request(int amtRequested, int priority)Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource. No partial filling- Parameters:
amtRequested-priority-
-
Request
public Request(int amtRequested, int priority, boolean allowPartialFilling)Creates a request with the supplied parameters Note: the request is not ready until it has been used within a resource.- Parameters:
amtRequested-priority-allowPartialFilling-
-
-
Method Detail
-
nullify
public void nullify()
Sets all internal references to null. Use only if the request is no longer needed.
-
setResourceAllocationListener
public final void setResourceAllocationListener(AllocationListenerIfc listener)
-
hasResourceAllocationListener
public final boolean hasResourceAllocationListener()
-
setResourceReleaseListener
public final void setResourceReleaseListener(ResourceReleaseListenerIfc releaseListener)
A ResourceReleaseListener can be attached to the request and provide behavior right after the request has release units of a resource.- Parameters:
releaseListener-
-
getArrivalNumber
public final int getArrivalNumber()
-
getPriority
public final int getPriority()
Gets the priority associated with the request- Returns:
- The priority as an int
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getEntity
public final Entity getEntity()
The Entity associated with the request- Returns:
-
getAmountNeeded
public final int getAmountNeeded()
Returns the amount needed by the request
-
getInitialAmountRequested
public final int getInitialAmountRequested()
Gets the original amount requested.- Returns:
- The original amount requested
-
getAmountAllocated
public final int getAmountAllocated()
Gets the amount allocated by the resource to the request- Returns:
- The amount of the resource given to the request
-
allowsPartialFilling
public final boolean allowsPartialFilling()
Indicates that the request allows the amount requested to be partially filled- Returns:
- Returns true if allowed
-
getSeizedResource
public final Resource getSeizedResource()
Gets the resource that the request is using- Returns:
- The resource or null if the request has not been used to seize resource
-
getSeizedResourceSet
public final ResourceSet getSeizedResourceSet()
If the request was made on a ResourceSet then this returns the relevent set (or null)- Returns:
-
getResourceSaveKey
public final java.lang.String getResourceSaveKey()
-
isSatisfied
public final boolean isSatisfied()
Indicates whether or not the request has been allocated its full amount, i.e. whether it has been satisfied The request is satisfied if the amount requested equals the amount allocated, i.e. it has been allocated all that it has requested.- Returns:
- true if the request is satisfied
-
isUnallocated
public final boolean isUnallocated()
Indicates whether the request has not been allocated any units from a resource- Returns:
-
isPartiallyAllocated
public final boolean isPartiallyAllocated()
Indicates whether the request has been partially allocated to a resource- Returns:
-
getResourceSelectionRule
public ResourceSelectionRuleIfc getResourceSelectionRule()
-
setResourceSelectionRule
public void setResourceSelectionRule(ResourceSelectionRuleIfc rule)
-
compareTo
public int compareTo(Request req)
Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object. Natural ordering: priority, then order of creation Lower priority, lower order of creation goes first Throws ClassCastException if the specified object's type prevents it from begin compared to this object. Throws RuntimeException if the id's of the objects are the same, but the references are not when compared with equals. Note: This class may have a natural ordering that is inconsistent with equals.- Specified by:
compareToin interfacejava.lang.Comparable<Request>- Parameters:
req- The requirement to compare this listener to- Returns:
- Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.
-
-