Package ru.objectsfill.utils
Class FieldUtils
java.lang.Object
ru.objectsfill.utils.FieldUtils
Utility class for working with fields in Java classes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TaddObjectWithParamConstruct(Constructor<?> constructor, Fill fill) create instance of class with construct parametersstatic <T> TaddObjectWithParamConstruct(Constructor<?> constructor, Fill fill, Class<?> tClass) create instance of class with construct parametersstatic voiddoWithFields(Fill fill) Invokes the given FieldCallback for each field in the specified class and its superclasses.getExtFillParam(Field field, Fill fill) static UnaryOperator<Object>getObjectUnaryOperator(Fill fill) get wrap function or default t -> t.static UnaryOperator<Object>getObjectUnaryOperator(Fill fill, Field field) get wrap function or default t -> t.
-
Method Details
-
doWithFields
Invokes the given FieldCallback for each field in the specified class and its superclasses.- Parameters:
fill- special generated object- Throws:
IllegalArgumentException- if the class is nullIllegalStateException- if the FieldCallback encounters an error while processing a field
-
addObjectWithParamConstruct
create instance of class with construct parameters- Type Parameters:
T- type of object- Parameters:
fill- special generated objectconstructor- get construct for object creation- Returns:
- T constructed object
- Throws:
IllegalArgumentException- if the class is nullIllegalStateException- if the FieldCallback encounters an error while processing a field
-
addObjectWithParamConstruct
public static <T> T addObjectWithParamConstruct(Constructor<?> constructor, Fill fill, Class<?> tClass) create instance of class with construct parameters- Type Parameters:
T- type of object- Parameters:
fill- special generated objectconstructor- get construct for object creationtClass- class of outer object for creation- Returns:
- T constructed object
- Throws:
IllegalArgumentException- if the class is nullIllegalStateException- if the FieldCallback encounters an error while processing a field
-
getObjectUnaryOperator
get wrap function or default t -> t. If we don't have reference to field- Parameters:
fill- the `Fill` object containing the generation parameters- Returns:
- function
-
getObjectUnaryOperator
get wrap function or default t -> t. If we don't have reference to field- Parameters:
fill- the `Fill` object containing the generation parametersfield- The field for which the collection stream is being filled.- Returns:
- function
-
getExtFillParam
- Parameters:
field- The field for which the collection stream is being filled.fill- The Fill object containing the necessary information for generation.- Returns:
- extended parameter for some field
-