Created
November 29, 2016 15:11
-
-
Save MosesMansaray/1238ae3f2f0be305d4e9ea990f445b90 to your computer and use it in GitHub Desktop.
Converts Class Object to Enum equivalent
This file contains hidden or 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 class ConvertObjectToEnumOneLineInstantiation { | |
/* | |
* To: | |
`HIGHLIGHT("highlight", false, "field", false, "title,description,body", null),` | |
* | |
* From: | |
* | |
`HIGHLIGHT { | |
public String getName() {return "highlight";} | |
public boolean isRequired() {return false;} | |
public String getLevel() {return "field";} | |
public boolean isExposed() {return false; } | |
public String getField() {return "title,description,body";} | |
public FieldTypes getParent() {return null;} | |
},` | |
*/ | |
public static void main(String[] args) throws Exception { | |
for (FieldTypes value : FieldTypes.values()) { | |
StringBuilder builder = new StringBuilder(); | |
builder.append(value.name()); | |
builder.append("("); | |
builder.append("\"" + value.getName() + "\","); | |
builder.append(value.isRequired() + ","); | |
builder.append("\"" + value.getLevel() + "\","); | |
builder.append(value.isExposed() + ","); | |
builder.append("\"" + value.getField() + "\","); | |
builder.append(value.getParent()); | |
builder.append("),"); | |
System.out.println(builder.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment