com.rosetta.testconditional.model.TestEnum Maven / Gradle / Ivy
package com.rosetta.testconditional.model;
import com.rosetta.model.lib.annotations.RosettaEnum;
import com.rosetta.model.lib.annotations.RosettaEnumValue;
import com.rosetta.model.lib.annotations.RosettaSynonym;
import com.rosetta.testconditional.model.TestEnum;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @version test
*/
@RosettaEnum("TestEnum")
public enum TestEnum {
@RosettaSynonym(value = "foo", source = "Bank_A")
@RosettaEnumValue(value = "FOO")
FOO("FOO", null),
@RosettaSynonym(value = "bar", source = "Bank_A")
@RosettaEnumValue(value = "BAR")
BAR("BAR", null)
;
private static Map values;
static {
Map map = new ConcurrentHashMap<>();
for (TestEnum instance : TestEnum.values()) {
map.put(instance.toDisplayString(), instance);
}
values = Collections.unmodifiableMap(map);
}
private final String rosettaName;
private final String displayName;
TestEnum(String rosettaName, String displayName) {
this.rosettaName = rosettaName;
this.displayName = displayName;
}
public static TestEnum fromDisplayName(String name) {
TestEnum value = values.get(name);
if (value == null) {
throw new IllegalArgumentException("No enum constant with display name \"" + name + "\".");
}
return value;
}
@Override
public String toString() {
return toDisplayString();
}
public String toDisplayString() {
return displayName != null ? displayName : rosettaName;
}
}