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 class
Request.State
Unallocated - 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 int
DEFAULT_PRIORITY
The 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 boolean
allowsPartialFilling()
Indicates that the request allows the amount requested to be partially filledint
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.int
getAmountAllocated()
Gets the amount allocated by the resource to the requestint
getAmountNeeded()
Returns the amount needed by the requestint
getArrivalNumber()
Entity
getEntity()
The Entity associated with the requestint
getInitialAmountRequested()
Gets the original amount requested.int
getPriority()
Gets the priority associated with the requestjava.lang.String
getResourceSaveKey()
ResourceSelectionRuleIfc
getResourceSelectionRule()
Resource
getSeizedResource()
Gets the resource that the request is usingResourceSet
getSeizedResourceSet()
If the request was made on a ResourceSet then this returns the relevent set (or null)boolean
hasResourceAllocationListener()
boolean
isPartiallyAllocated()
Indicates whether the request has been partially allocated to a resourceboolean
isSatisfied()
Indicates whether or not the request has been allocated its full amount, i.e.boolean
isUnallocated()
Indicates whether the request has not been allocated any units from a resourcevoid
nullify()
Sets all internal references to null.void
setResourceAllocationListener(AllocationListenerIfc listener)
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.void
setResourceSelectionRule(ResourceSelectionRuleIfc rule)
java.lang.String
toString()
-
-
-
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:
toString
in 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:
compareTo
in 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.
-
-