@FunctionalInterface
public interface ValueCalculator
Value
s given a series
of parameters.
For now this is split from ValueFactory
and the function can
be implemented in a way that all the calls to the specific value factory methods go through the
same function. It could be argued that instead of having a functional interface this could be a
new method in ValueFactory
, but until something like this is
needed in different location having a separate function looks cleaner.
Modifier and Type | Method and Description |
---|---|
Value |
apply(@NotNull java.lang.String type,
@Nullable Clazz referencedClass,
boolean isParticular,
@Nullable java.lang.Object concreteValue,
boolean valueMayBeExtension,
@Nullable java.lang.Object valueId)
|
Value apply(@NotNull @NotNull java.lang.String type, @Nullable @Nullable Clazz referencedClass, boolean isParticular, @Nullable @Nullable java.lang.Object concreteValue, boolean valueMayBeExtension, @Nullable @Nullable java.lang.Object valueId)
Value
given all available known information about it (included the actual
tracked value or a Model
of it, if available, and its reference identifier if the value
has the same reference as an existing one).
This method is not limited to particular value and can be used to create any value given the available amount of information.
type
- the static type of the created value (runtime type might implement/extend it).referencedClass
- the Clazz
of the value (if it's a reference value).isParticular
- whether the value to create is particular. If not the `concreteValue`
parameter will be ignored.concreteValue
- the value of the tracked object. Can be the actual value or a Model
.valueMayBeExtension
- whether the created value might actually be an extension of the
type. This should always be false for the instance created by constructors since they
always create an object of the exact type. This should usually be ClassUtil.isExtendable(Clazz)
for non constructor calls or more precise information if the
caller is able to provide it.valueId
- the already known reference identifier of the created value. Null if the
identifier was not previously known. This is particularly important for constructors, since
they always return void and the only way to associate the constructed object to its
existing references is via the valueId.Value
corresponding to the given parameters.