Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package tmp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Model {
public Map<String, Class> parameterTypes;
public Map<String, Object> defaultValues;
public Map<String, Object> currentValues;
public Model(List<IGenerator> generators) {
parameterTypes = new HashMap<String, Class>();
defaultValues = new HashMap<String, Object>();
currentValues = new HashMap<String, Object>();
for (IGenerator generator : generators) {
for (String parameterName : generator.getParameterNames()) {
public void register(String parameter, Class type, Object defaultValue) {
parameterTypes.put(parameter, type);
defaultValues.put(parameter, defaultValue);
public Object get(String parameterName) {
if (currentValues.containsKey(parameterName)) {
return currentValues.get(parameterName);
} else {
return defaultValues.get(parameterName);
public void set(String parameterName, Object value) throws Exception {
Class requiredClass = parameterTypes.get(parameterName);
if (value.getClass() == requiredClass) {
currentValues.put(parameterName, value);
} else {
throw new Exception();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment