Package me.ehp246.aufjms.core.reflection
Class DefaultProxyInvocation
java.lang.Object
me.ehp246.aufjms.core.reflection.DefaultProxyInvocation
- All Implemented Interfaces:
Invocation
public final class DefaultProxyInvocation extends java.lang.Object implements Invocation
- Since:
- 1.0
- Author:
- Lei Yang
-
Constructor Summary
Constructors Constructor Description DefaultProxyInvocation(java.lang.Class<?> declaringType, java.lang.Object target, java.lang.reflect.Method method, java.util.List<?> args) -
Method Summary
Modifier and Type Method Description java.util.List<?>args()Arguments of the invocation.booleancanReturn(java.lang.Class<?> type)booleancanThrow(java.lang.Class<?> type)<A extends java.lang.annotation.Annotation, V>
VclassAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper, java.util.function.Supplier<V> supplier)java.lang.Class<?>declaringType()java.util.List<?>filterPayloadArgs(java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> annotations)<R> java.util.List<R>findArgumentsOfType(java.lang.Class<R> type)Find all arguments of the given parameter type.<A extends java.lang.annotation.Annotation, V>
java.util.Optional<A>findOnDeclaringClass(java.lang.Class<A> annotationClass)Returns the value of the annotation or default if annotation is not found.<A extends java.lang.annotation.Annotation>
java.util.Optional<A>findOnMethod(java.lang.Class<A> annotationClass)<A extends java.lang.annotation.Annotation>
java.util.Optional<A>findOnMethodUp(java.lang.Class<A> annotationClass)<A extends java.lang.annotation.Annotation, V>
VfirstArgumentAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<AnnotatedArgument<A>,V> mapper, java.util.function.Supplier<V> supplier)java.lang.Class<?>getDeclaringClass()java.lang.StringgetDeclaringClassSimpleName()java.util.List<? extends java.lang.annotation.Annotation>getMethodDeclaredAnnotations()java.lang.StringgetMethodName()java.lang.Class<?>getReturnType()java.util.List<java.lang.Class<?>>getThrows()Void is considered a declared return.booleanhasReturn()booleanisAsync()booleanisSync()<K, V, A extends java.lang.annotation.Annotation>
java.util.Map<K,V>mapAnnotatedArguments(java.lang.Class<A> annotationType, java.util.function.Function<A,K> keySupplier)Looks for arguments that are annotated by the given Annotation type.java.lang.reflect.Methodmethod()The method that is invoked.<A extends java.lang.annotation.Annotation, V>
VmethodAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper, java.util.function.Supplier<V> supplier)<A extends java.lang.annotation.Annotation, V>
java.util.Optional<V>optionalValueOnMethod(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper)<A extends java.lang.annotation.Annotation, V>
VresolveAnnotatedValue(java.lang.Class<A> annotationClass, java.util.function.Function<AnnotatedArgument<A>,V> argMapper, java.util.function.Function<A,V> methodMapper, java.util.function.Function<A,V> classMapper, java.util.function.Supplier<V> supplier)Resolve the annotation value up the invocation hierarchy.<A extends java.lang.annotation.Annotation>
java.util.stream.Stream<AnnotatedArgument<A>>streamOfAnnotatedArguments(java.lang.Class<A> annotationType)java.lang.Objecttarget()The object on which the invocation is made.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
DefaultProxyInvocation
public DefaultProxyInvocation(java.lang.Class<?> declaringType, java.lang.Object target, java.lang.reflect.Method method, java.util.List<?> args)
-
-
Method Details
-
declaringType
public java.lang.Class<?> declaringType() -
target
public java.lang.Object target()Description copied from interface:InvocationThe object on which the invocation is made.- Specified by:
targetin interfaceInvocation
-
method
public java.lang.reflect.Method method()Description copied from interface:InvocationThe method that is invoked.- Specified by:
methodin interfaceInvocation
-
getMethodDeclaredAnnotations
public java.util.List<? extends java.lang.annotation.Annotation> getMethodDeclaredAnnotations() -
getDeclaringClass
public java.lang.Class<?> getDeclaringClass() -
getDeclaringClassSimpleName
public java.lang.String getDeclaringClassSimpleName() -
args
public java.util.List<?> args()Description copied from interface:InvocationArguments of the invocation.- Specified by:
argsin interfaceInvocation
-
getReturnType
public java.lang.Class<?> getReturnType() -
hasReturn
public boolean hasReturn() -
isAsync
public boolean isAsync() -
isSync
public boolean isSync() -
getThrows
public java.util.List<java.lang.Class<?>> getThrows()Void is considered a declared return.- Returns:
-
canThrow
public boolean canThrow(java.lang.Class<?> type) -
canReturn
public boolean canReturn(java.lang.Class<?> type) -
filterPayloadArgs
public java.util.List<?> filterPayloadArgs(java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> annotations) -
findOnDeclaringClass
public <A extends java.lang.annotation.Annotation, V> java.util.Optional<A> findOnDeclaringClass(java.lang.Class<A> annotationClass)Returns the value of the annotation or default if annotation is not found. -
findArgumentsOfType
public <R> java.util.List<R> findArgumentsOfType(java.lang.Class<R> type)Find all arguments of the given parameter type.- Type Parameters:
R- Parameter type- Parameters:
type- Class of the parameter type- Returns:
- all arguments of the given type. Could have
null.
-
mapAnnotatedArguments
public <K, V, A extends java.lang.annotation.Annotation> java.util.Map<K,V> mapAnnotatedArguments(java.lang.Class<A> annotationType, java.util.function.Function<A,K> keySupplier)Looks for arguments that are annotated by the given Annotation type. Returns a map with the key provided by the key supplier function, the value the argument.- Type Parameters:
K- Key from the key supplierV- Argument object referenceA- Annotation type- Parameters:
annotationType-keySupplier-- Returns:
- returned Map can be modified. Never
null.
-
streamOfAnnotatedArguments
public <A extends java.lang.annotation.Annotation> java.util.stream.Stream<AnnotatedArgument<A>> streamOfAnnotatedArguments(java.lang.Class<A> annotationType) -
optionalValueOnMethod
public <A extends java.lang.annotation.Annotation, V> java.util.Optional<V> optionalValueOnMethod(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper) -
firstArgumentAnnotationOf
public <A extends java.lang.annotation.Annotation, V> V firstArgumentAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<AnnotatedArgument<A>,V> mapper, java.util.function.Supplier<V> supplier) -
methodAnnotationOf
public <A extends java.lang.annotation.Annotation, V> V methodAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper, java.util.function.Supplier<V> supplier) -
classAnnotationOf
public <A extends java.lang.annotation.Annotation, V> V classAnnotationOf(java.lang.Class<A> annotationClass, java.util.function.Function<A,V> mapper, java.util.function.Supplier<V> supplier) -
resolveAnnotatedValue
public <A extends java.lang.annotation.Annotation, V> V resolveAnnotatedValue(java.lang.Class<A> annotationClass, java.util.function.Function<AnnotatedArgument<A>,V> argMapper, java.util.function.Function<A,V> methodMapper, java.util.function.Function<A,V> classMapper, java.util.function.Supplier<V> supplier)Resolve the annotation value up the invocation hierarchy. -
findOnMethod
public <A extends java.lang.annotation.Annotation> java.util.Optional<A> findOnMethod(java.lang.Class<A> annotationClass) -
findOnMethodUp
public <A extends java.lang.annotation.Annotation> java.util.Optional<A> findOnMethodUp(java.lang.Class<A> annotationClass) -
getMethodName
public java.lang.String getMethodName()
-