Class AbstractBuildingDependentRequestResolver<R extends IRequestable>

java.lang.Object
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractRequestResolver<R>
com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractBuildingDependentRequestResolver<R>
Type Parameters:
R - The type of request that they handle
All Implemented Interfaces:
IRequester, IRequestResolver<R>, IBuildingBasedRequester
Direct Known Subclasses:
BuildingRequestResolver

public abstract class AbstractBuildingDependentRequestResolver<R extends IRequestable> extends AbstractRequestResolver<R> implements IBuildingBasedRequester
Abstract class used as a base class for request resolver that handle request coming from the building they are originating from.
  • Constructor Details

    • AbstractBuildingDependentRequestResolver

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

    • canResolveRequest

      public boolean canResolveRequest(@NotNull @NotNull IRequestManager manager, IRequest<? extends R> 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.
      Specified by:
      canResolveRequest in interface IRequestResolver<R extends IRequestable>
      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.
    • canResolveForBuilding

      public abstract boolean canResolveForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends R> request, @NotNull @NotNull AbstractBuilding building)
    • attemptResolveRequest

      @Nullable public @Nullable List<IToken<?>> attemptResolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends R> 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!

      Specified by:
      attemptResolveRequest in interface IRequestResolver<R extends IRequestable>
      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.
    • attemptResolveForBuilding

      @Nullable public abstract @Nullable List<IToken<?>> attemptResolveForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends R> request, @NotNull @NotNull AbstractBuilding building)
    • resolveRequest

      public void resolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends R> 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

      Specified by:
      resolveRequest in interface IRequestResolver<R extends IRequestable>
      Parameters:
      manager - The manager that is resolving this request, under normal conditions this is the colony manager.
      request - The request to resolve.
    • resolveForBuilding

      public abstract void resolveForBuilding(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends R> request, @NotNull @NotNull AbstractBuilding building)
    • isValid

      public boolean isValid()
      Description copied from interface: IRequestResolver
      If this resolver has valid data in it.
      Specified by:
      isValid in interface IRequestResolver<R extends IRequestable>
      Returns:
      true if so.