
org.codehaus.groovy.reflection.GroovyClassValueFactory Maven / Gradle / Ivy
package org.codehaus.groovy.reflection;
import java.lang.reflect.Constructor;
import org.codehaus.groovy.reflection.GroovyClassValue.ComputeValue;
class GroovyClassValueFactory {
private static final Constructor groovyClassValueConstructor;
static {
Class groovyClassValueClass;
try{
Class.forName("java.lang.ClassValue");
try{
groovyClassValueClass = Class.forName("org.codehaus.groovy.reflection.v7.GroovyClassValueJava7");
}catch(Exception e){
throw new RuntimeException(e); // this should never happen, but if it does, let it propagate and be fatal
}
}catch(ClassNotFoundException e){
groovyClassValueClass = GroovyClassValuePreJava7.class;
}
try{
groovyClassValueConstructor = groovyClassValueClass.getConstructor(ComputeValue.class);
}catch(Exception e){
throw new RuntimeException(e); // this should never happen, but if it does, let it propagate and be fatal
}
}
public static GroovyClassValue createGroovyClassValue(ComputeValue computeValue){
try {
return (GroovyClassValue) groovyClassValueConstructor.newInstance(computeValue);
} catch (Exception e) {
throw new RuntimeException(e); // this should never happen, but if it does, let it propagate and be fatal
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy