260219_01_ENH: 유틸 분리 및 StringUtil 생성

This commit is contained in:
2026-02-20 09:44:55 +09:00
parent 5de2640c18
commit cca5a9b5be
4 changed files with 71 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
//버전 변경은 여기서
def commonVer = "beta.1.0.64"
def commonVer = "beta.1.0.66"
group = 'com.kri.common'
version = commonVer

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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();
}
}