[refactor] Makes enums more readable.
This commit is contained in:
@ -7,26 +7,16 @@ package com.iluwatar;
|
|||||||
*/
|
*/
|
||||||
public enum Size {
|
public enum Size {
|
||||||
|
|
||||||
SMALL, NORMAL, LARGE;
|
SMALL("small"), NORMAL("normal"), LARGE("large"), UNDEFINED("");
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
Size(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
return title;
|
||||||
String s = "";
|
|
||||||
|
|
||||||
switch (this) {
|
|
||||||
case LARGE:
|
|
||||||
s = "large";
|
|
||||||
break;
|
|
||||||
case NORMAL:
|
|
||||||
s = "normal";
|
|
||||||
break;
|
|
||||||
case SMALL:
|
|
||||||
s = "small";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,24 +7,16 @@ package com.iluwatar;
|
|||||||
*/
|
*/
|
||||||
public enum Visibility {
|
public enum Visibility {
|
||||||
|
|
||||||
VISIBLE, INVISIBLE;
|
VISIBLE("visible"), INVISIBLE("invisible"), UNDEFINED("");
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
Visibility(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
return title;
|
||||||
String s = "";
|
|
||||||
|
|
||||||
switch (this) {
|
|
||||||
case INVISIBLE:
|
|
||||||
s = "invisible";
|
|
||||||
break;
|
|
||||||
case VISIBLE:
|
|
||||||
s = "visible";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user