java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.adapters.quantity.QuantityAdapter
All Implemented Interfaces:
Adapter

public class QuantityAdapter extends Object implements Adapter
Adapter implementation for extracting quantity values from supported objects.

This adapter enables macro substitution for {OBJECT.QUANTITY} by adapting known types into Quantifiable instances. Supported types include:

  • Quantifiable — directly implemented by plugins
  • ItemStack — maps to getAmount()
  • Chest — maps to inventory size via getInventory().getSize()
  • Inventory — maps to inventory size via getSize()
  • Collection — maps to size()

Plugins may implement Quantifiable directly to add custom macro support for other object types.

See Also:
  • Constructor Details

    • QuantityAdapter

      public QuantityAdapter()
  • Method Details

    • adapt

      public Optional<Quantifiable> adapt(Object obj)
      Attempts to adapt the given object into a Quantifiable instance.
      Specified by:
      adapt in interface Adapter
      Parameters:
      obj - the object to adapt
      Returns:
      an Optional<Quantifiable> if the object is supported, otherwise empty