Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ♻️ rename the class DocJavaField some attribute #717

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/ly/doc/helper/FormDataBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public static List<FormData> getFormData(String className, Map<String, String> r
for (DocJavaField docField : fields) {
JavaField field = docField.getJavaField();
String fieldName = field.getName();
String subTypeName = docField.getFullyQualifiedName();
String fieldGicName = docField.getGenericCanonicalName();
String subTypeName = docField.getTypeFullyQualifiedName();
String fieldGicName = docField.getTypeGenericCanonicalName();
JavaClass javaClass = field.getType();
if (field.isStatic() || "this$0".equals(fieldName) ||
JavaClassValidateUtil.isIgnoreFieldTypes(subTypeName)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ly/doc/helper/JsonBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public static String buildJson(String typeName, String genericCanonicalName,
if (ignoreFields.containsKey(fieldName)) {
continue;
}
String subTypeName = docField.getFullyQualifiedName();
String subTypeName = docField.getTypeFullyQualifiedName();
if ((responseFieldToUnderline && isResp) || (requestFieldToUnderline && !isResp)) {
fieldName = StringUtil.camelToUnderline(fieldName);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ public static String buildJson(String typeName, String genericCanonicalName,
}
}
String typeSimpleName = docField.getTypeSimpleName();
String fieldGicName = docField.getGenericCanonicalName();
String fieldGicName = docField.getTypeGenericCanonicalName();
CustomField.Key key = CustomField.Key.create(docField.getDeclaringClassName(), fieldName);

CustomField customResponseField = CustomField.nameEquals(key, builder.getCustomRespFieldMap());
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/ly/doc/helper/ParamsBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.ly.doc.utils.JavaClassValidateUtil;
import com.power.common.model.EnumDictionary;
import com.power.common.util.CollectionUtil;
import com.power.common.util.StringEscapeUtil;
import com.power.common.util.StringUtil;
import com.ly.doc.builder.ProjectDocConfigBuilder;
import com.ly.doc.constants.DocTags;
Expand Down Expand Up @@ -176,12 +175,12 @@ public static List<ApiParam> buildParams(String className, String pre, int level
continue;
}

String subTypeName = docField.getFullyQualifiedName();
String subTypeName = docField.getTypeFullyQualifiedName();
if ((responseFieldToUnderline && isResp) || (requestFieldToUnderline && !isResp)) {
fieldName = StringUtil.camelToUnderline(fieldName);
}
String typeSimpleName = field.getType().getSimpleName();
String fieldGicName = docField.getGenericCanonicalName();
String fieldGicName = docField.getTypeGenericCanonicalName();
List<JavaAnnotation> javaAnnotations = docField.getAnnotations();

Map<String, String> tagsMap = DocUtil.getFieldTagsValue(field, docField);
Expand Down Expand Up @@ -375,7 +374,7 @@ public static List<ApiParam> buildParams(String className, String pre, int level
} else if (JavaClassValidateUtil.isCollection(subTypeName) || JavaClassValidateUtil.isArray(subTypeName)) {
if (isShowJavaType) {
// rpc
param.setType(JavaFieldUtil.convertToSimpleTypeName(docField.getGenericFullyQualifiedName()));
param.setType(JavaFieldUtil.convertToSimpleTypeName(docField.getTypeGenericFullyQualifiedName()));
} else {
param.setType("array");
}
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/ly/doc/model/DocJavaField.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DocJavaField {
/**
* comment
*/
private String Comment;
private String comment;

/**
* tags
Expand All @@ -55,17 +55,17 @@ public class DocJavaField {
/**
* field fullyQualifiedName
*/
private String fullyQualifiedName;
private String typeFullyQualifiedName;

/**
* field genericCanonicalName
*/
private String genericCanonicalName;
private String typeGenericCanonicalName;

/**
* genericFullyQualifiedName
*/
private String genericFullyQualifiedName;
private String typeGenericFullyQualifiedName;

/**
* field generic actualJavaType;
Expand Down Expand Up @@ -110,29 +110,29 @@ public DocJavaField setJavaField(JavaField javaField) {
}

public String getComment() {
return Comment;
return comment;
}

public DocJavaField setComment(String comment) {
Comment = comment;
this.comment = comment;
return this;
}

public String getFullyQualifiedName() {
return fullyQualifiedName;
public String getTypeFullyQualifiedName() {
return typeFullyQualifiedName;
}

public DocJavaField setFullyQualifiedName(String fullyQualifiedName) {
this.fullyQualifiedName = fullyQualifiedName;
public DocJavaField setTypeFullyQualifiedName(String typeFullyQualifiedName) {
this.typeFullyQualifiedName = typeFullyQualifiedName;
return this;
}

public String getGenericCanonicalName() {
return genericCanonicalName;
public String getTypeGenericCanonicalName() {
return typeGenericCanonicalName;
}

public DocJavaField setGenericCanonicalName(String genericCanonicalName) {
this.genericCanonicalName = genericCanonicalName;
public DocJavaField setTypeGenericCanonicalName(String typeGenericCanonicalName) {
this.typeGenericCanonicalName = typeGenericCanonicalName;
return this;
}

Expand Down Expand Up @@ -235,12 +235,12 @@ public DocJavaField setDeclaringClassName(String declaringClassName) {
return this;
}

public String getGenericFullyQualifiedName() {
return genericFullyQualifiedName;
public String getTypeGenericFullyQualifiedName() {
return typeGenericFullyQualifiedName;
}

public DocJavaField setGenericFullyQualifiedName(String genericFullyQualifiedName) {
this.genericFullyQualifiedName = genericFullyQualifiedName;
public DocJavaField setTypeGenericFullyQualifiedName(String typeGenericFullyQualifiedName) {
this.typeGenericFullyQualifiedName = typeGenericFullyQualifiedName;
return this;
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/ly/doc/utils/JavaClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Stri
List<DocJavaField> fields = getFields(cls1, counter, addedFields, actualJavaTypes, classLoader);

for (DocJavaField field : fields) {
String genericCanonicalName = field.getGenericCanonicalName();
String genericCanonicalName = field.getTypeGenericCanonicalName();
if (Objects.isNull(genericCanonicalName)) {
continue;
}
JavaType actualJavaType = actualJavaTypes.get(genericCanonicalName);
if (Objects.isNull(actualJavaType)) {
continue;
}
field.setGenericCanonicalName(genericCanonicalName.replace(genericCanonicalName, actualJavaType.getGenericCanonicalName()));
field.setFullyQualifiedName(field.getFullyQualifiedName().replace(genericCanonicalName, actualJavaType.getFullyQualifiedName()));
field.setTypeGenericCanonicalName(genericCanonicalName.replace(genericCanonicalName, actualJavaType.getGenericCanonicalName()));
field.setTypeFullyQualifiedName(field.getTypeFullyQualifiedName().replace(genericCanonicalName, actualJavaType.getFullyQualifiedName()));
field.setActualJavaType(actualJavaType.getFullyQualifiedName());
}
return fields;
Expand Down Expand Up @@ -134,10 +134,10 @@ private static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Str
.setComment(comment)
.setDocletTags(javaMethod.getTags())
.setAnnotations(javaMethod.getAnnotations())
.setFullyQualifiedName(javaField.getType().getFullyQualifiedName())
.setGenericCanonicalName(getReturnGenericType(javaMethod, classLoader))
.setGenericFullyQualifiedName(javaField.getType().getGenericFullyQualifiedName());

.setTypeFullyQualifiedName(javaField.getType().getFullyQualifiedName())
.setTypeGenericCanonicalName(getReturnGenericType(javaMethod, classLoader))
.setTypeGenericFullyQualifiedName(javaField.getType().getGenericFullyQualifiedName())
.setTypeSimpleName(javaField.getType().getSimpleName());
addedFields.put(methodName, docJavaField);
}
}
Expand Down Expand Up @@ -253,9 +253,9 @@ private static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Str
&& DocAnnotationConstants.TO_STRING_SERIALIZER_USING.equals(annotation.getNamedParameter("using")));
docJavaField.setComment(comment)
.setJavaField(javaField)
.setFullyQualifiedName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY: subTypeName)
.setGenericCanonicalName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY : gicName)
.setGenericFullyQualifiedName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY: fieldType.getGenericFullyQualifiedName())
.setTypeFullyQualifiedName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY: subTypeName)
.setTypeGenericCanonicalName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY : gicName)
.setTypeGenericFullyQualifiedName(isToString ? DocGlobalConstants.JAVA_STRING_FULLY: fieldType.getGenericFullyQualifiedName())
.setActualJavaType(actualType)
.setAnnotations(javaField.getAnnotations())
.setFieldName(fieldName)
Expand Down
Loading