Interface LimitedConsumer<T>

All Known Subinterfaces:
FluidInsertable, FluidTransferable, GroupedFluidInv, GroupedItemInv, ItemInsertable, ItemTransferable, LimitedGroupedFluidInv, LimitedGroupedItemInv
All Known Implementing Classes:
CombinedFluidInsertable, CombinedGroupedFluidInv, CombinedGroupedItemInv, CombinedItemInsertable, DelegatingGroupedFluidInv, DelegatingGroupedItemInv, DirectFixedItemInv, EmptyFluidTransferable, EmptyGroupedFluidInv, EmptyGroupedItemInv, EmptyItemTransferable, FilteredFluidInsertable, FilteredFluidTransferable, FilteredItemInsertable, FilteredItemTransferable, FullFixedItemInv, GroupedFluidInvFixedWrapper, GroupedItemInvFixedWrapper, ItemBasedSingleFluidInv, ItemTransferableItemEntity, JumboFixedFluidInv, RejectingFluidInsertable, RejectingItemInsertable, SimpleFixedFluidInv, SimpleFixedFluidInvInsertable, SimpleFixedItemInv, SimpleFixedItemInvInsertable, SimpleGroupedItemInv, SimpleLimitedGroupedFluidInv, SimpleLimitedGroupedItemInv, SingleCopyingItemSlot, SingleFluidTank, SingleItemSlot
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface LimitedConsumer<T>
A type of Consumer that may or may not accept a given input.
  • Method Details

    • offer

      boolean offer​(T object, Simulation simulation)
      Parameters:
      object - The object to offer. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in.
      simulation - If Simulation.ACTION then this will modify state (if accepted).
      Returns:
      True if the object would have been accepted.
    • offer

      default boolean offer​(T object)
      Parameters:
      object - The object to offer. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in
      Returns:
      True if the offer was accepted, or false if nothing happened.
    • wouldAccept

      default boolean wouldAccept​(T object)
      Parameters:
      object - The object to test for. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in
      Returns:
      True if the offer was accepted, or false if nothing happened.
    • rejecting

      static <T> LimitedConsumer<T> rejecting()
      Returns:
      A LimitedConsumer that rejects all inputs.
    • fromConsumer

      static <T> LimitedConsumer<T> fromConsumer​(java.util.function.Consumer<T> consumer)
      Creates a new LimitedConsumer that accepts everything, and passes it on to the given Consumer.