Class PickupRequestResolver

All Implemented Interfaces:
IRequester, IRequestResolver<Pickup>

public class PickupRequestResolver extends DeliverymenRequestResolver<Pickup>
Resolver that handles pickup requests. Pickups don't have much logic inherently, because the only important information are the requester and the priority. These resolvers are supposed to be provided by deliverymen.

Currently, this resolver will iterate through all available deliverymen and find the one with the least amount of open requests, followed by the one that is nearest.

There is a tiny bit of (known) code-smell in here, since this resolver should either be global or specific to a hut. Currently, it is a hut-specific resolver that acts as if it were global. The performance impact is negligible though.

  • Constructor Details

    • PickupRequestResolver

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

    • getSuitabilityMetric

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

      public boolean canResolveRequest(@NotNull @NotNull IRequestManager manager, IRequest<? extends Pickup> 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<Pickup>
      Overrides:
      canResolveRequest in class DeliverymenRequestResolver<Pickup>
      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.
    • getRequestType

      public com.google.common.reflect.TypeToken<? extends Pickup> 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.