Created
February 19, 2017 02:36
-
-
Save DaddyMoe/38992cc0249cbf19ce74e184056e2767 to your computer and use it in GitHub Desktop.
Converts Class Object to Enum equivalent
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 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