Created
February 8, 2016 11:19
-
-
Save gkazior/f70b20094e3a9d6e09cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum EntityType { | |
Customer("CS"), | |
ContactPerson("CP"); | |
EntityType(String symbol) { | |
this.symbol = symbol; | |
} | |
private String symbol; | |
public String getName() { | |
return name(); | |
} | |
public String getSymbol() { | |
return symbol; | |
} | |
public static EntityType nameToEntityType(String name) { | |
for (EntityType et: EntityType.values()) { | |
if (et.getName().equals(name)) { | |
return et; | |
} | |
} | |
throw new IllegalArgumentException(name + " cannot be converted to EntityType"); | |
} | |
public static EntityType symbolToEntityType(String symbol) { | |
for (EntityType et: EntityType.values()) { | |
if (et.symbol.equals(symbol)) { | |
return et; | |
} | |
} | |
throw new IllegalArgumentException(symbol + " cannot be converted to EntityType"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment