Revert "feat(common, other): support List parsing with target in GlowTrgmField"

This reverts commit 454570db56.
This commit is contained in:
jade
2026-07-09 13:37:08 +09:00
parent 454570db56
commit 5c7f1c92a2
4 changed files with 11 additions and 68 deletions

View File

@@ -22,8 +22,4 @@ public @interface GlowTrgmField {
*/ */
String description() default ""; String description() default "";
/**
* List 매핑 시 대상 클래스 (제네릭 타입 소거 우회용)
*/
Class<?> target() default void.class;
} }

View File

@@ -57,10 +57,10 @@ public class GlowTrgmParser {
} }
int endIndex = Math.min(currentIndex + length, trgmString.length()); int endIndex = Math.min(currentIndex + length, trgmString.length());
String value = trgmString.substring(currentIndex, endIndex); String value = trgmString.substring(currentIndex, endIndex).trim();
field.setAccessible(true); field.setAccessible(true);
setFieldValue(instance, field, value, annotation); setFieldValue(instance, field, value);
currentIndex += length; currentIndex += length;
} }
@@ -72,47 +72,21 @@ public class GlowTrgmParser {
} }
} }
private static void setFieldValue(Object instance, Field field, String value, GlowTrgmField annotation) throws IllegalAccessException { private static void setFieldValue(Object instance, Field field, String value) throws IllegalAccessException {
Class<?> fieldType = field.getType(); Class<?> fieldType = field.getType();
String trimmedValue = value.trim();
if (fieldType == String.class) { if (fieldType == String.class) {
field.set(instance, trimmedValue); field.set(instance, value);
} else if (fieldType == int.class || fieldType == Integer.class) { } else if (fieldType == int.class || fieldType == Integer.class) {
field.set(instance, trimmedValue.isEmpty() ? 0 : Integer.parseInt(trimmedValue)); field.set(instance, value.isEmpty() ? 0 : Integer.parseInt(value));
} else if (fieldType == long.class || fieldType == Long.class) { } else if (fieldType == long.class || fieldType == Long.class) {
field.set(instance, trimmedValue.isEmpty() ? 0L : Long.parseLong(trimmedValue)); field.set(instance, value.isEmpty() ? 0L : Long.parseLong(value));
} else if (fieldType == boolean.class || fieldType == Boolean.class) { } else if (fieldType == boolean.class || fieldType == Boolean.class) {
field.set(instance, Boolean.parseBoolean(trimmedValue)); field.set(instance, Boolean.parseBoolean(value));
} else if (fieldType == double.class || fieldType == Double.class) { } else if (fieldType == double.class || fieldType == Double.class) {
field.set(instance, trimmedValue.isEmpty() ? 0.0 : Double.parseDouble(trimmedValue)); field.set(instance, value.isEmpty() ? 0.0 : Double.parseDouble(value));
} else if (List.class.isAssignableFrom(fieldType)) {
Class<?> targetClass = annotation.target();
if (targetClass != void.class) {
List<Object> list = new ArrayList<>();
int itemLength = calculateTotalLength(targetClass);
if (itemLength > 0) {
for (int i = 0; i < value.length(); i += itemLength) {
int end = Math.min(i + itemLength, value.length());
String itemStr = value.substring(i, end);
if (itemStr.trim().isEmpty()) continue;
list.add(parse(itemStr, targetClass));
}
}
field.set(instance, list);
}
} else { } else {
field.set(instance, trimmedValue); field.set(instance, value);
} }
} }
private static int calculateTotalLength(Class<?> clazz) {
int total = 0;
for (Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(GlowTrgmField.class)) {
total += field.getAnnotation(GlowTrgmField.class).length();
}
}
return total;
}
} }

View File

@@ -33,6 +33,6 @@ public class SampleStringRes {
@GlowTrgmField(order = 4, length = 2, description = "상태코드") @GlowTrgmField(order = 4, length = 2, description = "상태코드")
private String statusCode; private String statusCode;
@GlowTrgmField(order = 5, length = 30, description = "타겟 리스트", target = SampleTargetDto.class) @GlowTrgmField(order = 5, length = 10, description = "타겟")
private java.util.List<SampleTargetDto> target; private String target;
} }

View File

@@ -1,27 +0,0 @@
package io.shinhanlife.axhub.biz.mcp.tool.dto;
import io.shinhanlife.glow.GlowTrgmField;
import lombok.Data;
/**
* @package io.shinhanlife.axhub.biz.mcp.tool.dto
* @className SampleTargetDto
* @description AX HUB 시스템 처리 클래스
* @author 김형식
* @create 2026.09.01
* <pre>
* ---------- 개정이력 ----------
* 수정일 수정자 수정내용
* ---------- -------- ---------------------------
* 2026.09.01 김형식 최초생성
*
* </pre>
*/
@Data
public class SampleTargetDto {
@GlowTrgmField(order = 1, length = 5, description = "항목 코드")
private String itemCode;
@GlowTrgmField(order = 2, length = 5, description = "항목 값")
private String itemValue;
}