1818 */
1919public class StringUtilities {
2020
21- private static final String COMMA_SEPARATOR = "," ;
22- private static final String PARAM_SEPARATOR = "=" ;
23- private static final String TYPE_SEPARATOR = ";" ;
24- private static final String DATEFORMAT_SEPARATOR = "@" ;
25- private static final String CONVERTOR_METHOD_NAME = "valueOf" ;
26- private static final String DATE_TYPE = "date" ;
27- private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss" ;
28- private static final String STRING_TYPE = "string" ;
29-
30- private static final Logger LOG = LoggerFactory .getLogger (StringUtilities .class );
31-
32- private static final HashMap <String , Class <?>> PRIMITIVE_NAME_TYPE_MAP = new HashMap <>();
33-
34- static {
35- PRIMITIVE_NAME_TYPE_MAP .put ("boolean" , Boolean .class );
36- PRIMITIVE_NAME_TYPE_MAP .put ("int" , Integer .class );
37- PRIMITIVE_NAME_TYPE_MAP .put ("long" , Long .class );
38- PRIMITIVE_NAME_TYPE_MAP .put ("float" , Float .class );
39- PRIMITIVE_NAME_TYPE_MAP .put ("double" , Double .class );
40- }
41-
42- /**
21+ private static final String COMMA_SEPARATOR = "," ;
22+ private static final String PARAM_SEPARATOR = "=" ;
23+ private static final String TYPE_SEPARATOR = ";" ;
24+ private static final String DATEFORMAT_SEPARATOR = "@" ;
25+ private static final String CONVERTOR_METHOD_NAME = "valueOf" ;
26+ private static final String DATE_TYPE = "date" ;
27+ private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss" ;
28+ private static final String STRING_TYPE = "string" ;
29+
30+ private static final Logger LOG = LoggerFactory .getLogger (StringUtilities .class );
31+
32+ private static final HashMap <String , Class <?>> PRIMITIVE_NAME_TYPE_MAP = new HashMap <>();
33+
34+ static {
35+ PRIMITIVE_NAME_TYPE_MAP .put ("boolean" , Boolean .class );
36+ PRIMITIVE_NAME_TYPE_MAP .put ("int" , Integer .class );
37+ PRIMITIVE_NAME_TYPE_MAP .put ("long" , Long .class );
38+ PRIMITIVE_NAME_TYPE_MAP .put ("float" , Float .class );
39+ PRIMITIVE_NAME_TYPE_MAP .put ("double" , Double .class );
40+ }
41+
42+ /**
43+ * Reverses the given string.
44+ * @param input the string to reverse
45+ * @return the reversed string
46+ */
47+ public static String reverseString (String input ) {
48+ if (input == null ) return null ;
49+ return new StringBuilder (input ).reverse ().toString ();
50+ }
51+
52+ /**
4353 * given a comma separated string and type, returns an ArrayList of specific types
4454 * @param strParamValueList The string (assumed to be comma separated). Usually meant for use in creating
4555 * parameter values for passing in IN Clauses
@@ -48,15 +58,15 @@ public class StringUtilities {
4858 */
4959 public static List <Object > convertStringToList (String strParamValueList ,String type ){
5060 if (strParamValueList == null || strParamValueList .isBlank ()) {
51- return null ;
52- }
53-
54- var list = new ArrayList <Object >();
55- var arr = strParamValueList .trim ().split (COMMA_SEPARATOR );
56- for (var tmpString : arr ) {
57- list .add (convert (tmpString , type ));
58- }
59- return list ;
61+ return null ;
62+ }
63+
64+ var list = new ArrayList <Object >();
65+ var arr = strParamValueList .trim ().split (COMMA_SEPARATOR );
66+ for (var tmpString : arr ) {
67+ list .add (convert (tmpString , type ));
68+ }
69+ return list ;
6070 }
6171
6272 /**
@@ -69,23 +79,23 @@ public static List<Object> convertStringToList(String strParamValueList,String t
6979 */
7080 public static HashMap <String , Object > createParameterList (String ... strParamValueList ){
7181 var hMap = new HashMap <String , Object >();
72- for (var strArg : strParamValueList ) {
73- String type = null ;
74- if (strArg .contains (TYPE_SEPARATOR )) {
75- var parts = strArg .split (TYPE_SEPARATOR );
76- type = parts [1 ];
77- strArg = parts [0 ];
78- }
79- if (strArg .contains (PARAM_SEPARATOR )) {
80- var arr = strArg .split (PARAM_SEPARATOR );
81- if (arr [1 ].contains (COMMA_SEPARATOR )) {
82- hMap .put (arr [0 ], convertStringToList (arr [1 ], type ));
83- } else {
84- hMap .put (arr [0 ], convert (arr [1 ], type ));
85- }
86- }
87- }
88- return hMap ;
82+ for (var strArg : strParamValueList ) {
83+ String type = null ;
84+ if (strArg .contains (TYPE_SEPARATOR )) {
85+ var parts = strArg .split (TYPE_SEPARATOR );
86+ type = parts [1 ];
87+ strArg = parts [0 ];
88+ }
89+ if (strArg .contains (PARAM_SEPARATOR )) {
90+ var arr = strArg .split (PARAM_SEPARATOR );
91+ if (arr [1 ].contains (COMMA_SEPARATOR )) {
92+ hMap .put (arr [0 ], convertStringToList (arr [1 ], type ));
93+ } else {
94+ hMap .put (arr [0 ], convert (arr [1 ], type ));
95+ }
96+ }
97+ }
98+ return hMap ;
8999 }
90100
91101 /**
@@ -97,8 +107,8 @@ public static HashMap<String, Object> createParameterList(String... strParamValu
97107 private static Object convert (String value , String types ) {
98108
99109 if (value == null || value .isBlank () || types == null || types .isBlank () || types .equalsIgnoreCase (STRING_TYPE )) {
100- return value ;
101- }
110+ return value ;
111+ }
102112
103113 var type = types .toLowerCase ();
104114 if (type .equals (DATE_TYPE )) {
0 commit comments