Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 34904

A data type consisting of a set of named values called elements, members or enumerators of the type.

7 votes
4 answers
5k views

Saving enum value using name()

Let's assume I have an enum type enum ComponentState { TURNED_OFF, TURNED_ON, SUSPENDED, TO_REPAIR; } This enum describes a state of some component. … try { state = ComponentState.valueOf(element.getAttributeValue("state")); } catch (IllegalArgumentException e) { //... } Everything is fine, but problems starts when I change the name of some enum
radekEm's user avatar
  • 934
0 votes
3 answers
822 views

Mixing business logic and presentation layer in enum type

Let's assume I have an enum type with currency: public enum CurrencyType { USD("American Dollar", "USD"), EUR("Euro", "EUR"), JPY("Japan Yen", "JPY"); private final String fullName; … private final String shortName; // enum valirables can change in the future, so I do not use Currency.name() private CurrencyType(String fullName, String shortName) { this.fullName = fullName …
radekEm's user avatar
  • 934