Class ExtractDerivedParameter<S,T>
Object
ExtractDerivedParameter<S,T>
- Type Parameters:
S
- type of parameter to extract from (source)T
- type of parameter that is maybe derived (target)
Extracts one type of parameter from another, if possible.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractIfPossible
(S parameter) Extracts a derived parameter if possible fromparameter
.Class
<?> The class of the target typeT
.
-
Constructor Details
-
ExtractDerivedParameter
Creates with only atargetClass
.- Parameters:
targetClass
- the class of the target type.extractionFunction
- a function to extract the target from the source.
-
ExtractDerivedParameter
public ExtractDerivedParameter(Class<?> targetClass, Function<S, T> extractionFunction, Class<?> sourceBaseClass) Creates with aclassOfTarget
and abaseClassOfSource
.- Parameters:
targetClass
- the class of the target type.extractionFunction
- a function to extract the target from the source.sourceBaseClass
- a class the source-param must be assignable to. It will be checked by reflection.
-
-
Method Details
-
extractIfPossible
Extracts a derived parameter if possible fromparameter
.- Parameters:
parameter
- the parameter to maybe derive an extracted parameter from.- Returns:
- the extracted parameter or
Optional.empty()
if it is not possible.
-
getTargetClass
The class of the target typeT
.
-