Created
September 16, 2021 17:57
-
-
Save dhruvilp/dbc5978cea5f3bd28f78acb3eb18776f to your computer and use it in GitHub Desktop.
Entity Variable Def Generator
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
import java.util.*; | |
import java.util.stream.*; | |
public class Main { | |
public static String dromedaryCamelCase(String inputStr) { | |
String bactrianCamel = Stream.of(inputStr.split("[^a-zA-Z0-9]")).filter(x -> x.length() > 0).map(v -> v.substring(0, 1).toUpperCase() + v.substring(1).toLowerCase()) .collect(Collectors.joining()); | |
return bactrianCamel.toLowerCase().substring(0, 1) + bactrianCamel.substring(1); | |
} | |
public static void classGen(String key, String value) { | |
String[] keys = key.split(","); | |
String[] values = value.split(","); | |
if(keys.length == values.length) { | |
for(int k=0; k < keys.length; ++k) { | |
String cc = dromedaryCamelCase(keys[k]); | |
System.out.printf("@Column(name=\"%s\")\nprivate %s %s;\n\n", keys[k], values[k], cc); | |
} | |
} else { | |
System.out.println("Length of keys and values do not match!"); | |
} | |
} | |
public static void main(String[] args) { | |
//=== CHANGE INPUT VALUES HERE === | |
String keys = "SYSTEM_ID,RETURN_CD,GOVT_SQLCODE_CD"; | |
String values = "String,BigDecimal,int"; | |
classGen(keys, values); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment