Package com.igormaznitsa.jbbp.model
Class JBBPFieldStruct
java.lang.Object
com.igormaznitsa.jbbp.model.JBBPAbstractField
com.igormaznitsa.jbbp.model.JBBPFieldStruct
- All Implemented Interfaces:
JBBPFieldFinder,JBBPNamedField,Serializable
Describes a structure.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields inherited from class com.igormaznitsa.jbbp.model.JBBPAbstractField
fieldNameInfo, payload -
Constructor Summary
ConstructorsConstructorDescriptionJBBPFieldStruct(JBBPNamedFieldInfo name, JBBPAbstractField[] fields) A Constructor.JBBPFieldStruct(JBBPNamedFieldInfo name, List<JBBPAbstractField> fields) A Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfindFieldForName(String name) Find a field for its name.<T extends JBBPAbstractField>
TfindFieldForNameAndType(String fieldName, Class<T> fieldType) Find a field for its name and type pair.findFieldForPath(String fieldPath) Find a field for its path.<T extends JBBPAbstractField>
TfindFieldForPathAndType(String fieldPath, Class<T> fieldType) Find a field for its path and type pair.<T extends JBBPAbstractField>
TfindFieldForType(Class<T> fieldType) Find unique field for defined class.<T extends JBBPAbstractField>
TfindFirstFieldForType(Class<T> fieldType) Find the first met field for defined class.<T extends JBBPAbstractField>
TfindLastFieldForType(Class<T> fieldType) Find the last met field for defined class.getArray()Get the fields of the structure as an array.Get the field type in string representation.final <T> TFind a structure by its path and map the structure fields to a class fields.final <T> TmapTo(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.final <T> TmapTo(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.final <T> TFind a structure by its path and map the structure fields to a class fields.final <T> TmapTo(T instance, int flags, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TMap the structure fields to object fields.final <T> TmapTo(T objectToMap, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TmapTo(T objectToMap, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TmapTo(T objectToMap, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TmapTo(T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TmapTo(T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>, Object>... instantiators) Map the structure fields to object fields.final <T> TMap the structure fields to object fields.booleannameExists(String fieldName) Check that a field exists for a namebooleanpathExists(String fieldPath) Check that a file exists for pathMethods inherited from class com.igormaznitsa.jbbp.model.JBBPAbstractField
getFieldName, getFieldPath, getNameInfo, getPayload, setPayload
-
Constructor Details
-
JBBPFieldStruct
A Constructor.- Parameters:
name- a field name info, it can be nullfields- a field array, it must not be null
-
JBBPFieldStruct
A Constructor.- Parameters:
name- a field name info, it can be nullfields- a field list, it must not be null
-
-
Method Details
-
getArray
Get the fields of the structure as an array.- Returns:
- the field array of the structure.
-
findFieldForPath
Description copied from interface:JBBPFieldFinderFind a field for its path.- Specified by:
findFieldForPathin interfaceJBBPFieldFinder- Parameters:
fieldPath- the field path for search, it must not be null- Returns:
- found field or null
-
findFieldForName
Description copied from interface:JBBPFieldFinderFind a field for its name.- Specified by:
findFieldForNamein interfaceJBBPFieldFinder- Parameters:
name- the field name for search, it must not be null- Returns:
- found field or null
-
findFieldForType
Description copied from interface:JBBPFieldFinderFind 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:
findFieldForTypein interfaceJBBPFieldFinder- 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
Description copied from interface:JBBPFieldFinderFind the first met field for defined class. Field should be exactly instance of the class, not a successor.- Specified by:
findFirstFieldForTypein interfaceJBBPFieldFinder- Type Parameters:
T- the class of the field- Parameters:
fieldType- the field class for search- Returns:
- found field or null
-
findLastFieldForType
Description copied from interface:JBBPFieldFinderFind the last met field for defined class. Field should be exactly instance of the class, not a successor.- Specified by:
findLastFieldForTypein interfaceJBBPFieldFinder- 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:JBBPFieldFinderFind a field for its name and type pair.- Specified by:
findFieldForNameAndTypein interfaceJBBPFieldFinder- Type Parameters:
T- the class of the field- Parameters:
fieldName- the field name for search, must not be nullfieldType- the field class for search, must not be null- Returns:
- found field or null
-
nameExists
Description copied from interface:JBBPFieldFinderCheck that a field exists for a name- Specified by:
nameExistsin interfaceJBBPFieldFinder- Parameters:
fieldName- a field name to check, it must not be null- Returns:
- true if the field exists, false otherwise
-
pathExists
Description copied from interface:JBBPFieldFinderCheck that a file exists for path- Specified by:
pathExistsin interfaceJBBPFieldFinder- 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:JBBPFieldFinderFind a field for its path and type pair.- Specified by:
findFieldForPathAndTypein interfaceJBBPFieldFinder- Type Parameters:
T- the class of the field- Parameters:
fieldPath- the field path for search, must not be nullfieldType- 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 nullinstance- object instance to be filled by values, must not be nullinstantiators- 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 nullinstance- object instance to be filled by values, must not be nullflags- special flags to tune mapping processinstantiators- 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 nullinstance- object instance to be filled by values, must not be nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldinstantiators- 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 nullinstance- object instance to be filled by values, must not be nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldflags- special flags to tune mapping processinstantiators- 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
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 nullinstantiators- 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 nullbinFieldFilter- filter allows to exclude some fields from process, can be nullinstantiators- 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 nullflags- special flags to tune mapping processinstantiators- 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 nullflags- special flags to tune mapping processbinFieldFilter- filter to exclude some fields from process, can be nullinstantiators- 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 nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldinstantiators- 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 nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldbinFieldFilter- filter to exclude some fields, can be nullinstantiators- 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 nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldflags- special flags to tune mapping processinstantiators- 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 nullcustomFieldProcessor- a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom fieldflags- special flags to tune mapping processbinFieldFilter- filter to exclude some fields, can be nullinstantiators- 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
Description copied from class:JBBPAbstractFieldGet the field type in string representation.- Specified by:
getTypeAsStringin classJBBPAbstractField- Returns:
- the string representation of field type, like 'int', 'long', 'bool [123]'
-