
com.mysema.codegen.MethodEvaluator Maven / Gradle / Ivy
/**
*
*/
package com.mysema.codegen;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.annotation.Nullable;
/**
* @author tiwe
*
* @param
*/
public final class MethodEvaluator implements Evaluator {
private final Method method;
@Nullable
private final Object object;
private final Class extends T> projectionType;
MethodEvaluator(Method method, @Nullable Object object, Class extends T> projectionType) {
this.method = method;
this.object = object;
this.projectionType = projectionType;
}
@SuppressWarnings("unchecked")
@Override
public T evaluate(Object... args) {
try {
return (T) method.invoke(object, args);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
@Override
public Class extends T> getType() {
return projectionType;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy