Skip to content

Commit 8e44b82

Browse files
[maven-tool] 修改检视意见
1 parent 98a41ad commit 8e44b82

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

framework/fel/java/maven-plugins/tool-maven-plugin/src/main/java/modelengine/fel/maven/complie/parser/ByteBuddySchemaParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import modelengine.fel.tool.info.entity.ReturnPropertyEntity;
1515
import modelengine.fel.tool.info.entity.SchemaEntity;
1616
import modelengine.fitframework.annotation.Property;
17+
import modelengine.fitframework.annotation.util.PropertyHelper;
18+
import modelengine.fitframework.util.StringUtils;
1719

1820
import net.bytebuddy.description.annotation.AnnotationDescription;
1921
import net.bytebuddy.description.method.MethodDescription;
@@ -115,11 +117,11 @@ private static PropertyEntity parseProperty(ParameterDescription parameterDescri
115117
entity.setDescription(property.description());
116118
entity.setNeed(property.required());
117119
String defaultValue = property.defaultValue();
118-
if (defaultValue != null && !defaultValue.isEmpty()) {
120+
if (defaultValue != null && PropertyHelper.isCustomValue(property.defaultValue())) {
119121
entity.setDefaultValue(defaultValue);
120122
}
121123
String example = property.example();
122-
if (example != null && !example.isEmpty()) {
124+
if (StringUtils.isNotEmpty(example)) {
123125
entity.setExamples(Collections.singletonList(example));
124126
}
125127
}
@@ -135,7 +137,7 @@ private static ReturnPropertyEntity parseReturnProperty(MethodDescription method
135137
returnPropertyEntity.setName(property.name());
136138
returnPropertyEntity.setDescription(property.description());
137139
String example = property.example();
138-
if (example != null && !example.isEmpty()) {
140+
if (StringUtils.isNotEmpty(example)) {
139141
returnPropertyEntity.setExamples(Collections.singletonList(example));
140142
}
141143
}

framework/fel/java/services/tool-service/src/main/java/modelengine/fel/tool/support/MethodToolMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import modelengine.fel.tool.annotation.Group;
1414
import modelengine.fel.tool.annotation.ToolMethod;
1515
import modelengine.fitframework.annotation.Property;
16+
import modelengine.fitframework.annotation.util.PropertyHelper;
1617
import modelengine.fitframework.json.schema.JsonSchemaManager;
1718
import modelengine.fitframework.util.MapBuilder;
1819
import modelengine.fitframework.util.StringUtils;
@@ -68,7 +69,7 @@ public Object parameterDefaultValue(String name) {
6869
Property annotation = parameter.getDeclaredAnnotation(Property.class);
6970
if (annotation != null) {
7071
String defaultValue = annotation.defaultValue();
71-
if (defaultValue != null && !defaultValue.isEmpty()) {
72+
if (defaultValue != null && PropertyHelper.isCustomValue(annotation.defaultValue())) {
7273
return defaultValue;
7374
}
7475
}

framework/fit/java/fit-util/src/main/java/modelengine/fitframework/annotation/Property.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
@Retention(RetentionPolicy.RUNTIME)
2525
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
2626
public @interface Property {
27+
/**
28+
* 表示未设置默认值的标记常量。
29+
*/
30+
String UNSET_DEFAULT_VALUE = "$$Fit$UnsetDefaultValue$$";
31+
2732
/**
2833
* 获取参数的名字。
2934
*
@@ -50,7 +55,7 @@
5055
*
5156
* @return 表示参数的默认值的 {@link String}。
5257
*/
53-
String defaultValue() default StringUtils.EMPTY;
58+
String defaultValue() default UNSET_DEFAULT_VALUE;
5459

5560
/**
5661
* 获取参数的样例值。
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fitframework.annotation.util;
8+
9+
import modelengine.fitframework.annotation.Property;
10+
11+
/**
12+
* 为 Property 注解提供工具类。
13+
*
14+
* @author 杭潇
15+
* @since 2025-10-29
16+
*/
17+
public final class PropertyHelper {
18+
/**
19+
* 隐藏默认构造方法,避免工具类被实例化。
20+
*/
21+
private PropertyHelper() {}
22+
23+
/**
24+
* 判断给定的默认值是否为设置状态。
25+
*
26+
* @param defaultValue 要检查的默认值。
27+
* @return 如果自定义参数值则返回 {@code true},否则返回 {@code false}。
28+
*/
29+
public static boolean isCustomValue(String defaultValue) {
30+
return !Property.UNSET_DEFAULT_VALUE.equals(defaultValue);
31+
}
32+
}
33+

0 commit comments

Comments
 (0)