Class AbstractKeyedMapLogic<TYPE_KEY,TYPE_LOGIC,TYPE_OUTPUT>

java.lang.Object
xyz.ronella.trivial.handy.AbstractKeyedMapLogic<TYPE_KEY,TYPE_LOGIC,TYPE_OUTPUT>
Type Parameters:
TYPE_KEY - The type of the key that can be matched.
TYPE_LOGIC - The type of logic that the map will hold.
TYPE_OUTPUT - The type of output that the logic will create.
Direct Known Subclasses:
AbstractBooleanSupplierKeyedMapLogic, AbstractStringKeyedMapLogic

public abstract class AbstractKeyedMapLogic<TYPE_KEY,TYPE_LOGIC,TYPE_OUTPUT> extends Object
The base class of the KeyedMapLogic implementations.
Since:
2.4.0
  • Field Details

    • internalMap

      protected final Map<TYPE_KEY,TYPE_LOGIC> internalMap
      The instance of Map received.
    • defaultLogic

      protected final TYPE_LOGIC defaultLogic
      Holds the default logic if the key doesn't exist in internalMap.
  • Constructor Details

    • AbstractKeyedMapLogic

      public AbstractKeyedMapLogic(Map<TYPE_KEY,TYPE_LOGIC> map, TYPE_LOGIC defaultLogic, List<Map.Entry<TYPE_KEY,TYPE_LOGIC>> logics)
      A standard way of creating an instance of AbstractKeyedMapLogic
      Parameters:
      map - The map that holds the keyed map logics.
      defaultLogic - The default logic if no matching key was found.
      logics - The logics that will be stored to the map parameter.
  • Method Details

    • getDefaultLogic

      public TYPE_LOGIC getDefaultLogic()
      The default logic that will be executed if none of the keys matched.
      Returns:
      The default logic.
    • handleDefaultLogicConstructorArgument

      protected abstract TYPE_LOGIC handleDefaultLogicConstructorArgument(TYPE_LOGIC defaultLogic)
      Must have the implementation to handle the null defaultLogic.
      Parameters:
      defaultLogic - The default argument received from the constructor.
      Returns:
      The initial value of the internal defaultLogic.