edu.uci.qa.performancedriver.result.GenericResultFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of performancedriver Show documentation
Show all versions of performancedriver Show documentation
A performance measuring API with high performance and portability
The newest version!
package edu.uci.qa.performancedriver.result;
import java.lang.reflect.InvocationTargetException;
import edu.uci.qa.performancedriver.thread.ResultId;
public class GenericResultFactory implements ResultFactory {
private final Class clzz;
// TODO: Check for public access (or give itself access)
public GenericResultFactory(Class clzz) {
this.clzz = clzz;
try {
clzz.getConstructor(ResultId.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new IllegalArgumentException("Result class must have a 1 arg ResultId constructor"
+ " in order to use the GenericResultFactory!");
}
}
@Override
public T create(ResultId id) {
try {
return clzz.getConstructor(ResultId.class).newInstance(id);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e);
}
}
}