Class Reflect
java.lang.Object
io.github.joselion.springr2dbcrelationships.helpers.Reflect
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @Nullable TFinds and invokes the getter of a field in the provided target.static <T> @Nullable TFinds and invokes the getter of a field in the provided target.static <T> @Nullable TFinds and invokes the getter of a field in the provided target.Curried version ofgetter(Object, Field)overload.Curried version ofgetter(Object, String)overload.static <T> Class<T> innerTypeOf(Field field) Returns the first inner type of a field's type.static <T> Function<T, @Nullable T> Curried version ofupdate(Object, Field, Object)overload.static <T> Function<T, @Nullable T> Curried version ofupdate(Object, String, Object)overload.static <T> @Nullable TUpdates a field using either a wither or a setter method.static <T> @Nullable TUpdates a field using either a wither or a setter method.
-
Method Details
-
getter
Finds and invokes the getter of a field in the provided target.- Type Parameters:
T- the return type of the getter- Parameters:
target- the target instance were the getter is invokedfield- the field to invoke the getter- Returns:
- the result of invoking the getter
- Throws:
ReflectException- if the getter method cannot be found or fails to be invoked
-
getter
Curried version ofgetter(Object, Field)overload.- Type Parameters:
T- the return type of the getter- Parameters:
field- the field to invoke the getter- Returns:
- a function that takes the target as parameter and returns the result of invoking the getter of the field
-
getter
Finds and invokes the getter of a field in the provided target.- Type Parameters:
T- the return type of the getter- Parameters:
target- the target instance were the getter is invokedfieldName- the name of the field to invoke the getter- Returns:
- the result of invoking the getter
- Throws:
ReflectException- if the getter method cannot be found or fails to be invoked
-
getter
Curried version ofgetter(Object, String)overload.- Type Parameters:
T- the return type of the getter- Parameters:
fieldName- the name of the field to invoke the getter- Returns:
- a function that takes the target as parameter and returns the result of invoking the getter of the field
-
getter
Finds and invokes the getter of a field in the provided target.- Type Parameters:
T- the return type of the getter- Parameters:
target- the target instance were the getter is invokedmethod- the method of the getter to invoke- Returns:
- the result of invoking the getter
- Throws:
ReflectException- if the getter method cannot be found or fails to be invoked
-
update
Updates a field using either a wither or a setter method. Then returns the target with the updated field.- Type Parameters:
T- the target type- Parameters:
target- the target instance where the field is updatedfield- the field to updatevalue- the value to update the field to- Returns:
- the updated target
- Throws:
ReflectException- if the wither/setter method cannot be found or fails to be invoked
-
update
Curried version ofupdate(Object, Field, Object)overload.- Type Parameters:
T- the target type- Parameters:
field- the field to updatevalue- the value to update the field to- Returns:
- a function that takes the target as argument and returns the updated target
-
update
Updates a field using either a wither or a setter method. Then returns the target with the updated field.- Type Parameters:
T- the target type- Parameters:
target- the target instance where the field is updatedfieldName- the field name to updatevalue- the value to update the field to- Returns:
- the updated target
- Throws:
ReflectException- if the wither/setter method cannot be found or fails to be invoked
-
update
Curried version ofupdate(Object, String, Object)overload.- Type Parameters:
T- the target type- Parameters:
fieldName- the field name to updatevalue- the value to update the field to- Returns:
- a function that takes the target as argument and returns the updated target
-
innerTypeOf
Returns the first inner type of a field's type.- Type Parameters:
T- the type of the generic- Parameters:
field- the field to find the inner type- Returns:
- the inner type of a field's type
- Throws:
ReflectException- if the field's type does not have an inner generic type
-