Skip to content

Instantly share code, notes, and snippets.

@StillManic
Created December 31, 2015 20:46
Show Gist options
  • Save StillManic/30268d99316e829c87f5 to your computer and use it in GitHub Desktop.
Save StillManic/30268d99316e829c87f5 to your computer and use it in GitHub Desktop.
public static class GroupConfig
{
public enum DataKeys
{
CHANGE("change", Lists.<String>newArrayList()),
OPERATION("operation", OBJState.Operation.SET_TRUE),
DEFAULT_OPERATION("defOperation", OBJState.Operation.SET_FALSE),
MODIFY_ALL_GROUPS("modifyAll", false);
public final String key;
public final Object initialValue;
DataKeys(String key, Object initialValue)
{
this.key = key;
this.initialValue = initialValue;
}
}
protected static Map<String, DataKeys> keyLookUp = Maps.newHashMapWithExpectedSize(DataKeys.values().length);
protected EnumMap<DataKeys, Object> dataMap = Maps.newEnumMap(DataKeys.class);
public String name;
public GroupConfig(String name)
{
this.name = name;
initDataMap();
}
private void initDataMap()
{
for (DataKeys key : DataKeys.values())
{
keyLookUp.put(key.key, key);
this.dataMap.put(key, key.initialValue);
}
}
public Object getValueForDataKey(DataKeys key)
{
return this.dataMap.get(key);
}
public void setValueForDataKey(DataKeys key, Object value)
{
this.dataMap.put(key, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment