Interface ReflectiveConstraint
- All Known Implementing Classes:
ClassTypeConstraint,VisibilityConstraint
@Experimental
public interface ReflectiveConstraint
A set of checks performed on a
ReflectiveHandle to determine whether it meets
certain requirements based on its JVM signature before we can use it.
Usually these are conditions that the standard Java's reflection API
doesn't care about. For example, Class.forName(String) doesn't
care whether the class is an enum/interface/abstract, but you could
add these additional checks using ClassTypeConstraint.
If the check against appliesTo(ReflectiveHandle, Object) fails,
a ReflectiveConstraintException should be thrown.
All constraints must be incompatible with each other. Menaing that two different constraints from the same class/category should not be able to co-exist.
This class should not be directly used in most cases.
- Since:
- 12.0.0
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription@NotNull ReflectiveConstraint.ResultappliesTo(@NotNull ReflectiveHandle<?> handle, @NotNull Object jvm) Whether this constraint can be applied and applies to the given item.category()The category name of this constraint.name()The name of this constraint.
-
Method Details
-
category
The category name of this constraint. -
name
The name of this constraint. -
appliesTo
@NotNull @Contract(pure=true) @NotNull ReflectiveConstraint.Result appliesTo(@NotNull @NotNull ReflectiveHandle<?> handle, @NotNull @NotNull Object jvm) Whether this constraint can be applied and applies to the given item.Usually a
ReflectiveConstraintExceptionshould be thrown if the result is eitherReflectiveConstraint.Result.INCOMPATIBLEorReflectiveConstraint.Result.NOT_MATCHED.- Parameters:
handle- the reflective handle of the object.jvm- the corresponding JVM object (notMethodHandle) of the handle.- Returns:
- Refer to
ReflectiveConstraint.Resultfor details.
-