Class JBBPFieldStruct

java.lang.Object
com.igormaznitsa.jbbp.model.JBBPAbstractField
com.igormaznitsa.jbbp.model.JBBPFieldStruct
All Implemented Interfaces:
JBBPFieldFinder, JBBPNamedField, Serializable

public final class JBBPFieldStruct extends JBBPAbstractField implements JBBPFieldFinder
Describes a structure.
Since:
1.0
See Also:
  • Constructor Details

    • JBBPFieldStruct

      public JBBPFieldStruct(JBBPNamedFieldInfo name, JBBPAbstractField[] fields)
      A Constructor.
      Parameters:
      name - a field name info, it can be null
      fields - a field array, it must not be null
    • JBBPFieldStruct

      public JBBPFieldStruct(JBBPNamedFieldInfo name, List<JBBPAbstractField> fields)
      A Constructor.
      Parameters:
      name - a field name info, it can be null
      fields - a field list, it must not be null
  • Method Details

    • getArray

      public JBBPAbstractField[] getArray()
      Get the fields of the structure as an array.
      Returns:
      the field array of the structure.
    • 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
    • findFieldForName

      public JBBPAbstractField findFieldForName(String name)
      Description copied from interface: JBBPFieldFinder
      Find a field for its name.
      Specified by:
      findFieldForName in interface JBBPFieldFinder
      Parameters:
      name - the field name for search, it 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
    • 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
    • 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
    • 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
    • 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
    • mapTo

      @SafeVarargs public final <T> T mapTo(String path, T instance, Function<Class<?>,Object>... instantiators)
      Find a structure by its path and map the structure fields to a class fields.
      Type Parameters:
      T - a class type
      Parameters:
      path - the path to the structure to be mapped, must not be null
      instance - object instance to be filled by values, must not be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      a mapped instance of the class, must not be null
      Since:
      2.0.0
    • mapTo

      @SafeVarargs public final <T> T mapTo(String path, T instance, int flags, Function<Class<?>,Object>... instantiators)
      Find a structure by its path and map the structure fields to a class fields.
      Type Parameters:
      T - a class type
      Parameters:
      path - the path to the structure to be mapped, must not be null
      instance - object instance to be filled by values, must not be null
      flags - special flags to tune mapping process
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      a mapped instance of the class, must not be null
      Since:
      2.0.0
      See Also:
    • mapTo

      @SafeVarargs public final <T> T mapTo(String path, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>,Object>... instantiators)
      Find a structure by its path and map the structure fields to a class fields.
      Type Parameters:
      T - a class type
      Parameters:
      path - the path to the structure to be mapped, must not be null
      instance - object instance to be filled by values, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      a mapped instance of the class, must not be null
      Since:
      2.0.0
    • mapTo

      @SafeVarargs public final <T> T mapTo(String path, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>,Object>... instantiators)
      Find a structure by its path and map the structure fields to a class fields.
      Type Parameters:
      T - a class type
      Parameters:
      path - the path to the structure to be mapped, must not be null
      instance - object instance to be filled by values, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      flags - special flags to tune mapping process
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      a mapped instance of the class, must not be null
      Since:
      2.0.0
      See Also:
    • mapTo

      @SafeVarargs public final <T> T mapTo(T objectToMap, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      objectToMap - an object to map fields of the structure, must not be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
    • mapTo

      @SafeVarargs public final <T> T mapTo(T objectToMap, BinFieldFilter binFieldFilter, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      objectToMap - an object to map fields of the structure, must not be null
      binFieldFilter - filter allows to exclude some fields from process, can be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      2.0.4
    • mapTo

      @SafeVarargs public final <T> T mapTo(T instance, int flags, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      instance - object instance to be filled by values, must not be null
      flags - special flags to tune mapping process
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      2.0.0
      See Also:
    • mapTo

      @SafeVarargs public final <T> T mapTo(T instance, int flags, BinFieldFilter binFieldFilter, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      instance - object instance to be filled by values, must not be null
      flags - special flags to tune mapping process
      binFieldFilter - filter to exclude some fields from process, can be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      2.0.4
      See Also:
    • mapTo

      @SafeVarargs public final <T> T mapTo(T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      instance - an object to map fields of the structure, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
    • mapTo

      @SafeVarargs public final <T> T mapTo(T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, BinFieldFilter binFieldFilter, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      instance - an object to map fields of the structure, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      binFieldFilter - filter to exclude some fields, can be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      2.0.4
    • mapTo

      @SafeVarargs public final <T> T mapTo(T objectToMap, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      objectToMap - an object to map fields of the structure, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      flags - special flags to tune mapping process
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      1.1
      See Also:
    • mapTo

      @SafeVarargs public final <T> T mapTo(T objectToMap, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, BinFieldFilter binFieldFilter, Function<Class<?>,Object>... instantiators)
      Map the structure fields to object fields.
      Type Parameters:
      T - expected result type
      Parameters:
      objectToMap - an object to map fields of the structure, must not be null
      customFieldProcessor - a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
      flags - special flags to tune mapping process
      binFieldFilter - filter to exclude some fields, can be null
      instantiators - array of functions which can instantiate object of required class, must not be null
      Returns:
      the same object from the arguments but with filled fields by values of the structure
      Since:
      2.0.4
      See Also:
    • getTypeAsString

      public String getTypeAsString()
      Description copied from class: JBBPAbstractField
      Get the field type in string representation.
      Specified by:
      getTypeAsString in class JBBPAbstractField
      Returns:
      the string representation of field type, like 'int', 'long', 'bool [123]'