io.crnk.rs.internal.legacy.provider.Parameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crnk-rs Show documentation
Show all versions of crnk-rs Show documentation
JSON API framework for Java
package io.crnk.rs.internal.legacy.provider;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
public class Parameter {
private final Method method;
private final int parameterIndex;
public Parameter(Method method, int parameterIndex) {
this.method = method;
this.parameterIndex = parameterIndex;
}
public Class> getType() {
return method.getParameterTypes()[parameterIndex];
}
public T getAnnotation(Class clazz) {
Annotation[] annotations = method.getParameterAnnotations()[parameterIndex];
for (Annotation annotation : annotations) {
if (clazz.isAssignableFrom(annotation.getClass())) {
return (T) annotation;
}
}
return null;
}
public boolean isAnnotationPresent(Class extends Annotation> clazz) {
Annotation[] annotations = method.getParameterAnnotations()[parameterIndex];
for (Annotation annotation : annotations) {
if (clazz.isAssignableFrom(annotation.getClass())) {
return true;
}
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy