All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 projectionType;

    MethodEvaluator(Method method, @Nullable Object object, Class 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 getType() {
        return projectionType;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy