diff --git a/build.gradle b/build.gradle index e671d33..901e5ac 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } //버전 변경은 여기서 -def commonVer = "beta.1.0.64" +def commonVer = "beta.1.0.66" group = 'com.kri.common' version = commonVer diff --git a/src/main/java/com/kri/common/util/CommonUtil.java b/src/main/java/com/kri/common/util/CommonUtil.java index a290767..6f1d086 100644 --- a/src/main/java/com/kri/common/util/CommonUtil.java +++ b/src/main/java/com/kri/common/util/CommonUtil.java @@ -4,44 +4,10 @@ import java.util.UUID; public final class CommonUtil { + private CommonUtil() { + } + public static String uuid32() { return UUID.randomUUID().toString().replace("-", ""); } - - public static boolean isNumeric(String s) { - if (s == null || s.isBlank()) { - return false; - } - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (c < '0' || c > '9') { - return false; - } - } - return true; - } - - public static short safeParseShort(String s, short def) { - try { - return Short.parseShort(s); - } catch (Exception e) { - return def; - } - } - - public static int safeParseInt(String s, short def) { - try { - return Integer.parseInt(s); - } catch (Exception e) { - return def; - } - } - - public static long safeParseLong(String s, short def) { - try { - return Long.parseLong(s); - } catch (Exception e) { - return def; - } - } } diff --git a/src/main/java/com/kri/common/util/NumericUtil.java b/src/main/java/com/kri/common/util/NumericUtil.java new file mode 100644 index 0000000..4c57f9e --- /dev/null +++ b/src/main/java/com/kri/common/util/NumericUtil.java @@ -0,0 +1,45 @@ +package com.kri.common.util; + +public final class NumericUtil { + + private NumericUtil() { + } + + public static boolean isNumeric(String s) { + if (s == null || s.isBlank()) { + return false; + } + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (c < '0' || c > '9') { + return false; + } + } + return true; + } + + public static short safeParseShort(String s, short def) { + try { + return Short.parseShort(s); + } catch (Exception e) { + return def; + } + } + + public static int safeParseInt(String s, short def) { + try { + return Integer.parseInt(s); + } catch (Exception e) { + return def; + } + } + + public static long safeParseLong(String s, short def) { + try { + return Long.parseLong(s); + } catch (Exception e) { + return def; + } + } + +} diff --git a/src/main/java/com/kri/common/util/StringUtil.java b/src/main/java/com/kri/common/util/StringUtil.java new file mode 100644 index 0000000..11a4c4d --- /dev/null +++ b/src/main/java/com/kri/common/util/StringUtil.java @@ -0,0 +1,22 @@ +package com.kri.common.util; + +public final class StringUtil { + + private StringUtil() { + } + + /** null 또는 "" 인지 */ + public static boolean isNullOrEmpty(String s) { + return s == null || s.isEmpty(); + } + + /** null 또는 공백(whitespace)만 있는지 ("" 포함) - Java 11+ */ + public static boolean isNullOrBlank(String s) { + return s == null || s.isBlank(); + } + + /** (옵션) 반대 버전도 같이 두면 실무에서 더 편함 */ + public static boolean hasText(String s) { + return s != null && !s.isBlank(); + } +}