public interface ReflectionConstructable
Due to Java's type erasure, only the number of arguments can be used to
distinguish several implemented interfaces derived from
ReflectionConstructable
. Therefore, ReflectionConstructable1
to ReflectionConstructable10
have been created. If a class inherits
ReflectionConstructable2
and ReflectionConstructable3
, it
must implement the appropriate two createInstance methods. If it shall be
constructable using different parameters, it just can implement
ReflectionConstructable4
, if necessary with superset of the desired
parameters.
Java does not allow an interface to enforce a static method. Therefore, a
custom annotation processor ReflectionConstructableProcessor
can be
used to check for the correct implementation in the derived classes at
compile time. However, this check is optional. If not implemented correctly,
this could lead to runtime errors when loading a class via reflection which
does not implement the correct static method.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CREATE_INSTANCE_METHOD_NAME |
static final java.lang.String CREATE_INSTANCE_METHOD_NAME