Package com.igormaznitsa.jbbp.mapper
Class JBBPMapper
java.lang.Object
com.igormaznitsa.jbbp.mapper.JBBPMapper
The Class processes mapping of a parsed binary data to class fields.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFlag to not throw exception if structure doesn't have value for a field.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear internal class field cache.static List<MappedFieldRecord> findAffectedFields(Object instance, BinFieldFilter binFieldFilter) static intGet current number of classes which fields are cached in internal field cache.static <T> Tmap(JBBPFieldStruct root, String structPath, T instance, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.static <T> Tmap(JBBPFieldStruct root, String structPath, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.static <T> Tmap(JBBPFieldStruct root, String structPath, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.static <T> Tmap(JBBPFieldStruct root, String structPath, T instance, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.static <T> Tmap(JBBPFieldStruct root, T instance, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure to the instance and return it.static <T> Tmap(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.static <T> Tmap(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.static <T> Tmap(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.static <T> Tmap(JBBPFieldStruct root, T instance, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure to the instance and return it.
-
Field Details
-
MAKE_CLASS_INSTANCE_METHOD_NAME
- See Also:
-
FLAG_IGNORE_MISSING_VALUES
public static final int FLAG_IGNORE_MISSING_VALUESFlag to not throw exception if structure doesn't have value for a field.- Since:
- 1.1
- See Also:
-
-
Constructor Details
-
JBBPMapper
public JBBPMapper()
-
-
Method Details
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, String structPath, T instance, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be used as the root, must not be nullstructPath- the path of a structure inside the root to be mapped to the class, must not be nullinstance- object to be filled by values, must not be nullinstantiators- functions to produce class instance by request, must not be null- Returns:
- the created and mapped instance of the mapping class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, String structPath, T instance, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be used as the root, must not be nullstructPath- the path of a structure inside the root to be mapped to the class, must not be nullinstance- object to be filled by values, must not be nullflags- special flags to tune mapping processinstantiators- functions to produce class instance by request, must not be null- Returns:
- the created and mapped instance of the mapping class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
- See Also:
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, String structPath, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be used as the root, must not be nullstructPath- the path of a structure inside the root to be mapped to the class, must not be nullinstance- instance to be filled by values, must not be nullcustomFieldProcessor- a custom field processor to provide custom values, it can be null if there is not any mapping field desires the processorinstantiators- functions produce class instance by request, must not be null- Returns:
- the created and mapped instance of the mapping class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, String structPath, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure for its path to its fields and return the instance.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be used as the root, must not be nullstructPath- the path of a structure inside the root to be mapped to the class, must not be nullinstance- object to be filled by values, must not be nullcustomFieldProcessor- a custom field processor to provide custom values, it can be null if there is not any mapping field desires the processorflags- special flags to tune mappinginstantiators- functions produce class instance by request, must not be null- Returns:
- the created and mapped instance of the mapping class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
- See Also:
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, T instance, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure to the instance and return it. It will create a class instance through a hack method and its constructor will not be called, thus use the method carefully.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be mapped to the class instance, must not be nullinstance- object instance to be filled by values, must not be nullinstantiators- functions produce class instance by request, must not be null- Returns:
- the created and mapped instance of the class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct root, T instance, int flags, Function<Class<?>, Object>... instantiators) Create a class instance, map binary data of a structure to the instance and return it. It will create a class instance through a hack method and its constructor will not be called, thus use the method carefully.- Type Parameters:
T- the mapping class type- Parameters:
root- a parsed structure to be mapped to the class instance, must not be nullinstance- the class to be instantiated and mapped, must not be nullflags- special flags to tune mapping processinstantiators- functions produce class instance by request, must not be null- Returns:
- the created and mapped instance of the class
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.0
- See Also:
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.- Type Parameters:
T- the mapping class type- Parameters:
rootStructure- a structure to be mapped, must not be nullinstance- a class instance to be destination for map operations, must not be nullcustomFieldProcessor- a custom field processor to provide custom values, it can be null if there is not any mapping field desires the processorinstantiators- functions to produce class instance by request, must not be null- Returns:
- the processed class instance, the same which was the argument for the method.
- Throws:
JBBPMapperException- for any error
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.- Type Parameters:
T- the mapping class type- Parameters:
rootStructure- a structure to be mapped, must not be nullinstance- a class instance to be destination for map operations, must not be nullcustomFieldProcessor- a custom field processor to provide custom values, it can be null if there is not any mapping field desires the processorflags- special flags for mapping processinstantiators- functions to produce class instance by request, must not be null- Returns:
- the processed class instance, the same which was the argument for the method.
- Throws:
JBBPMapperException- for any error- Since:
- 1.1
- See Also:
-
map
@SafeVarargs public static <T> T map(JBBPFieldStruct rootStructure, T instance, JBBPMapperCustomFieldProcessor customFieldProcessor, int flags, BinFieldFilter binFieldFilter, Function<Class<?>, Object>... instantiators) Map a structure to a class instance.- Type Parameters:
T- the mapping class type- Parameters:
rootStructure- a structure to be mapped, must not be nullinstance- a class instance to be destination for map operations, must not be nullcustomFieldProcessor- a custom field processor to provide custom values, it can be null if there is not any mapping field desires the processorflags- special flags for mapping processbinFieldFilter- filter allows to exclude some fields from process, can be nullinstantiators- functions to produce class instance by request, must not be null- Returns:
- the processed class instance, the same which was the argument for the method.
- Throws:
JBBPMapperException- for any error- Since:
- 2.0.4
- See Also:
-
getFieldCacheSize
public static int getFieldCacheSize()Get current number of classes which fields are cached in internal field cache.- Returns:
- number of classes
- Since:
- 2.0.0
-
clearFieldCache
public static void clearFieldCache()Clear internal class field cache.- Since:
- 2.0.0
-
findAffectedFields
public static List<MappedFieldRecord> findAffectedFields(Object instance, BinFieldFilter binFieldFilter)
-