Class JBBPNamedNumericFieldMap

java.lang.Object
com.igormaznitsa.jbbp.JBBPNamedNumericFieldMap
All Implemented Interfaces:
JBBPFieldFinder

public final class JBBPNamedNumericFieldMap extends Object implements JBBPFieldFinder
Implements a storage to keep named fields. it is not a thread-safe one
Since:
1.0
  • Constructor Details

    • JBBPNamedNumericFieldMap

      public JBBPNamedNumericFieldMap()
      Empty constructor which makes a map with null provider.
    • JBBPNamedNumericFieldMap

      public JBBPNamedNumericFieldMap(JBBPExternalValueProvider externalValueProvider)
      A Constructor.
      Parameters:
      externalValueProvider - an external value provider, it can be null
  • Method Details

    • getExternalValueProvider

      public JBBPExternalValueProvider getExternalValueProvider()
      Get the external value provider.
      Returns:
      the external value provider or null if it is undefined
    • get

      public JBBPNumericField get(JBBPNamedFieldInfo namedField)
      Get a numeric field for its field name info.
      Parameters:
      namedField - a field name info, it must not be null
      Returns:
      the found field or null if it is not found
    • putField

      public void putField(JBBPNumericField field)
      Put a numeric field into map.
      Parameters:
      field - a field to be added into map or replace already exists one, it must not be null
      Throws:
      NullPointerException - if the field is null or if it is an anonymous field
    • remove

      public JBBPNumericField remove(JBBPNamedFieldInfo nameInfo)
      Remove a field for its field name info descriptor.
      Parameters:
      nameInfo - the field name info, it must not be null
      Returns:
      removed numeric field or null if there was not any field for the info
    • findForFieldOffset

      public JBBPNumericField findForFieldOffset(int offset)
      Find a registered field for its field offset in compiled script.
      Parameters:
      offset - the field offset
      Returns:
      found field or null if there is not any found for the offset
    • findFirstFieldForType

      public <T extends JBBPAbstractField> T findFirstFieldForType(Class<T> fieldType)
      Description copied from interface: JBBPFieldFinder
      Find the first met field for defined class. Field should be exactly instance of the class, not a successor.
      Specified by:
      findFirstFieldForType in interface JBBPFieldFinder
      Type Parameters:
      T - the class of the field
      Parameters:
      fieldType - the field class for search
      Returns:
      found field or null
    • findLastFieldForType

      public <T extends JBBPAbstractField> T findLastFieldForType(Class<T> fieldType)
      Description copied from interface: JBBPFieldFinder
      Find the last met field for defined class. Field should be exactly instance of the class, not a successor.
      Specified by:
      findLastFieldForType in interface JBBPFieldFinder
      Type Parameters:
      T - the class of the field
      Parameters:
      fieldType - the field class for search, must not be null
      Returns:
      found field or null
    • findFieldForType

      public <T extends JBBPAbstractField> T findFieldForType(Class<T> fieldType)
      Description copied from interface: JBBPFieldFinder
      Find unique field for defined class. Field should be exactly instance of the class and the field must be only one or not be presented else an exception will be thrown.
      Specified by:
      findFieldForType in interface JBBPFieldFinder
      Type Parameters:
      T - the class of the field
      Parameters:
      fieldType - the field class for search, must not be null
      Returns:
      found field or null
    • findFieldForNameAndType

      public <T extends JBBPAbstractField> T findFieldForNameAndType(String fieldName, Class<T> fieldType)
      Description copied from interface: JBBPFieldFinder
      Find a field for its name and type pair.
      Specified by:
      findFieldForNameAndType in interface JBBPFieldFinder
      Type Parameters:
      T - the class of the field
      Parameters:
      fieldName - the field name for search, must not be null
      fieldType - the field class for search, must not be null
      Returns:
      found field or null
    • findFieldForPathAndType

      public <T extends JBBPAbstractField> T findFieldForPathAndType(String fieldPath, Class<T> fieldType)
      Description copied from interface: JBBPFieldFinder
      Find a field for its path and type pair.
      Specified by:
      findFieldForPathAndType in interface JBBPFieldFinder
      Type Parameters:
      T - the class of the field
      Parameters:
      fieldPath - the field path for search, must not be null
      fieldType - the field class for search, must not be null
      Returns:
      found field or null
    • findFieldForName

      public JBBPAbstractField findFieldForName(String fieldName)
      Description copied from interface: JBBPFieldFinder
      Find a field for its name.
      Specified by:
      findFieldForName in interface JBBPFieldFinder
      Parameters:
      fieldName - the field name for search, it must not be null
      Returns:
      found field or null
    • findFieldForPath

      public JBBPAbstractField findFieldForPath(String fieldPath)
      Description copied from interface: JBBPFieldFinder
      Find a field for its path.
      Specified by:
      findFieldForPath in interface JBBPFieldFinder
      Parameters:
      fieldPath - the field path for search, it must not be null
      Returns:
      found field or null
    • nameExists

      public boolean nameExists(String fieldName)
      Description copied from interface: JBBPFieldFinder
      Check that a field exists for a name
      Specified by:
      nameExists in interface JBBPFieldFinder
      Parameters:
      fieldName - a field name to check, it must not be null
      Returns:
      true if the field exists, false otherwise
    • pathExists

      public boolean pathExists(String fieldPath)
      Description copied from interface: JBBPFieldFinder
      Check that a file exists for path
      Specified by:
      pathExists in interface JBBPFieldFinder
      Parameters:
      fieldPath - a field path to check, it must not be null
      Returns:
      true if the field exists, false otherwise
    • clear

      public void clear()
      Clear the map.
    • isEmpty

      public boolean isEmpty()
      Check that the map is empty.
      Returns:
      true if the map is empty, false otherwise
    • size

      public int size()
      Get number of registered fields in the map.
      Returns:
      number of registered fields as integer
    • getExternalFieldValue

      public int getExternalFieldValue(String externalFieldName, JBBPCompiledBlock compiledBlock, JBBPIntegerValueEvaluator evaluator)
      Ask the registered external value provider for a field value.
      Parameters:
      externalFieldName - the name of a field, it must not be null
      compiledBlock - the compiled block, it must not be null
      evaluator - an evaluator which is calling the method, it can be null
      Returns:
      integer value for the field
      Throws:
      JBBPException - if there is not any external value provider