From cca5a9b5befc7d8230721d83e5297adcbd0937f1 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 20 Feb 2026 09:44:55 +0900 Subject: [PATCH] =?UTF-8?q?260219=5F01=5FENH:=20=EC=9C=A0=ED=8B=B8=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20StringUtil=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../java/com/kri/common/util/CommonUtil.java | 40 ++--------------- .../java/com/kri/common/util/NumericUtil.java | 45 +++++++++++++++++++ .../java/com/kri/common/util/StringUtil.java | 22 +++++++++ 4 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/kri/common/util/NumericUtil.java create mode 100644 src/main/java/com/kri/common/util/StringUtil.java 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(); + } +}