Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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()) {
register(parameterName,
generator.getParameterType(parameterName),
generator.getParameterDefault(parameterName));
}
}
}
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
Something went wrong with that request. Please try again.