Class AggregateReflectiveHandle<T,H extends ReflectiveHandle<T>>
java.lang.Object
com.cryptomorin.xseries.reflection.aggregate.AggregateReflectiveHandle<T,H>
- Type Parameters:
T- the JVM type ofAggregateReflectiveHandleH- the types of handles that are going to be checked.
- All Implemented Interfaces:
ReflectiveHandle<T>
public class AggregateReflectiveHandle<T,H extends ReflectiveHandle<T>>
extends Object
implements ReflectiveHandle<T>
Most reflection APIs already provide a name-based fallback system that can be used (like
DynamicClassHandle.named(String...))
but sometimes the signature of certain JVM declarations just change entirely, that's where this class could be useful.
It simply tries the reflect() method of each handle until one of them returns without throwing an exception (order matters).
Usage
MethodMemberHandle profileByName = XReflection.of(GameProfileCache.class).method().named("getProfile", "a");
MethodHandle getProfileByName = XReflection.anyOf(
() -> profileByName.signature("public GameProfile get(String username);"),
() -> profileByName.signature("public Optional<GameProfile> get(String username);")
).reflect();
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAggregateReflectiveHandle(Collection<Callable<H>> handles) UseXReflection.anyOf(Callable[])instead. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a new handle with the same properties.@NotNull ReflectiveHandle<ReflectedObject> jvm()UsuallyReflectiveHandles returnMethodHandlewhen possible, however this method returns the raw object using the traditional Java reflection API which can be:FieldMethodConstructorClass (same as its normal ReflectiveHandle)Action performed on all the handles before being checked.reflect()The heart of the class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.cryptomorin.xseries.reflection.ReflectiveHandle
cached, catchError, exists, reflectOrNull, unreflect, unwrap
-
Constructor Details
-
AggregateReflectiveHandle
UseXReflection.anyOf(Callable[])instead.
-
-
Method Details
-
or
- See Also:
-
or
- See Also:
-
modify
Action performed on all the handles before being checked. -
getHandle
-
copy
Description copied from interface:ReflectiveHandleCreates a new handle with the same properties.- Specified by:
copyin interfaceReflectiveHandle<T>
-
jvm
Description copied from interface:ReflectiveHandleUsuallyReflectiveHandles returnMethodHandlewhen possible, however this method returns the raw object using the traditional Java reflection API which can be:- Specified by:
jvmin interfaceReflectiveHandle<T>- See Also:
-
reflect
Description copied from interface:ReflectiveHandleThe heart of the class.- Specified by:
reflectin interfaceReflectiveHandle<T>- Returns:
- the final JVM object that exists in this runtime.
- Throws:
ReflectiveOperationException- if any errors occur while getting the object, including unknown objects, security issues, etc...- See Also:
-