Class AbstractWarehouseRequestResolver

java.lang.Object
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractRequestResolver<IDeliverable>
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractWarehouseRequestResolver
All Implemented Interfaces:
IRequester, IRequestResolver<IDeliverable>
Direct Known Subclasses:
WarehouseConcreteRequestResolver, WarehouseRequestResolver

public abstract class AbstractWarehouseRequestResolver extends AbstractRequestResolver<IDeliverable>
----------------------- Not Documented Object ---------------------
  • Constructor Details

    • AbstractWarehouseRequestResolver

      public AbstractWarehouseRequestResolver(@NotNull @NotNull ILocation location, @NotNull @NotNull IToken<?> token)
  • Method Details

    • getRequestType

      public com.google.common.reflect.TypeToken<? extends IDeliverable> getRequestType()
      Description copied from interface: IRequestResolver
      Used to determine which type of requests can be resolved by this Resolver.
      Returns:
      The class that represents this Type of Request this resolver can resolve.
    • getWarehouseInternalCount

      protected abstract int getWarehouseInternalCount(BuildingWareHouse wareHouse, IRequest<? extends IDeliverable> requestToCheck)
      Override to implement specific warehouse counting rules.
      Parameters:
      wareHouse - the warehouse to check.
      requestToCheck - the requested item.
      Returns:
      the available quantity.
    • canResolveRequest

      public boolean canResolveRequest(@NotNull @NotNull IRequestManager manager, IRequest<? extends IDeliverable> requestToCheck)
      Description copied from interface: IRequestResolver
      A PreCheck used to determine if this request resolver is able to resolve a given request. Should quickly and cheaply check if this resolver COULD resolve this request.
      Parameters:
      manager - The manager that is checking if this resolver could resolve that request.
      requestToCheck - The request to check.
      Returns:
      True when this resolver COULD resolve the given request, false when not.
    • isRequestChainValid

      public boolean isRequestChainValid(@NotNull @NotNull IRequestManager manager, IRequest<?> requestToCheck)
      Use to verify that a request chain is valid, and doesn't contain recursive cycles.
      Parameters:
      manager -
      requestToCheck -
      Returns:
    • attemptResolveRequest

      @Nullable public @Nullable List<IToken<?>> attemptResolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request)
      Description copied from interface: IRequestResolver
      Method used to attempt a resolving operation.

      When this attempt was successful a List with tokens of required requests is returned. This list maybe empty. The list should indicate all sub requests that should be fullfilled before the @code{resolve(IRequest request)} method is called.

      When this attempt was not successful, eg. this resolver could not schedule a crafting operation, a Null object should be returned. In that case the next resolver will be tried by the manager.

      IT IS VITAL THAT THE REQUEST RETURNED ARE NOT YET ASSIGNED. SIMULATION AND OTHER STRATEGIES WILL FAIL ELSE! THE MANAGER GIVEN WILL HANDLE ASSIGNING HIMSELF!

      Parameters:
      manager - The manager that is attempting to resolve using this resolver.
      request - The request to resolve.
      Returns:
      The tokens of required requests if the attempt was successful (an empty list is allowed to indicate no requirements), null if the attempt failed.
    • resolveRequest

      public void resolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request)
      Description copied from interface: IRequestResolver
      Method used to resolve a given request. Is called the moment all Child requests are resolved.

      The resolver should update the state through the given manager.

      When this method is called all requirements need be fullfilled for this resolver. If this is not the case it will throw a RunTimeException

      Parameters:
      manager - The manager that is resolving this request, under normal conditions this is the colony manager.
      request - The request to resolve.
    • getFollowupRequestForCompletion

      @Nullable public @Nullable List<IRequest<?>> getFollowupRequestForCompletion(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> completedRequest)
    • onAssignedRequestBeingCancelled

      public void onAssignedRequestBeingCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request)
      Description copied from interface: IRequestResolver
      Indicates that an assigned request has been cancelled. Is called before graph is updated.
      Parameters:
      manager - The manager that indicates the cancelling
      request - The request that has been cancelled.
    • onAssignedRequestCancelled

      public void onAssignedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request)
      Description copied from interface: IRequestResolver
      Indicates that an assigned request has been cancelled. Is called after the graph has been updated.
      Parameters:
      manager - The manager that indicates the cancelling
      request - The request that has been cancelled.
    • onRequestedRequestComplete

      public void onRequestedRequestComplete(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Method called by the request system to notify this requester that a request is complete.
      Parameters:
      manager - the request manager.
      request - the request.
    • onRequestedRequestCancelled

      public void onRequestedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Method called by the request system to notify this requester that a request has been overruled.
      Parameters:
      manager - the request manager.
      request - the request.
    • getRequesterDisplayName

      @NotNull public @NotNull net.minecraft.network.chat.MutableComponent getRequesterDisplayName(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Gets the name of the requester that requested the request given by the token.
      Specified by:
      getRequesterDisplayName in interface IRequester
      Overrides:
      getRequesterDisplayName in class AbstractRequestResolver<IDeliverable>
      Parameters:
      manager - the request manager.
      request - the request for which the name of the requester is retrieved
      Returns:
      The display name of the requester.
    • getPriority

      public int getPriority()
      Description copied from interface: IRequestResolver
      The priority of this resolver. The higher the priority the earlier this resolver is called.
      Specified by:
      getPriority in interface IRequestResolver<IDeliverable>
      Overrides:
      getPriority in class AbstractRequestResolver<IDeliverable>
      Returns:
      The priority of this resolver.
    • isValid

      public boolean isValid()
      Description copied from interface: IRequestResolver
      If this resolver has valid data in it.
      Returns:
      true if so.
    • getSuitabilityMetric

      public int getSuitabilityMetric(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request)
      Description copied from interface: IRequestResolver
      Check how suitable this resolver is for the request.
      Specified by:
      getSuitabilityMetric in interface IRequestResolver<IDeliverable>
      Overrides:
      getSuitabilityMetric in class AbstractRequestResolver<IDeliverable>
      Parameters:
      manager - the req manager.
      request - the request to check.
      Returns:
      the suitability metric (an int for easy comparison).