Добавил поле CLASS_NAME в SimpleMode

This commit is contained in:
Struchkov Mark 2023-01-24 13:18:56 +03:00
parent f83a3b235f
commit 8e79e74c0b
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
3 changed files with 17 additions and 18 deletions

View File

@ -1,8 +1,7 @@
package dev.struchkov.haiti.utils.fieldconstants.creator;
import dev.struchkov.haiti.utils.fieldconstants.domain.mode.simple.SimpleFieldDto;
import dev.struchkov.haiti.utils.fieldconstants.domain.mode.table.SimpleTableFieldDto;
import dev.struchkov.haiti.utils.fieldconstants.domain.mode.simple.ClassSimpleDto;
import dev.struchkov.haiti.utils.fieldconstants.domain.mode.simple.SimpleFieldDto;
import javax.annotation.processing.ProcessingEnvironment;
import javax.tools.JavaFileObject;
@ -27,7 +26,7 @@ public final class CreatorClassSimpleMode {
public static void record(ClassSimpleDto classDto, ProcessingEnvironment environment) {
JavaFileObject builderFile = null;
try {
builderFile = environment.getFiler().createSourceFile(classDto.getClassName());
builderFile = environment.getFiler().createSourceFile(classDto.getNewClassName());
} catch (IOException e) {
e.printStackTrace();
}
@ -36,8 +35,9 @@ public final class CreatorClassSimpleMode {
out.println("package " + classDto.getClassPackage() + ";");
out.println();
out.println();
out.print(format("public class {0} '{'", classDto.getClassName()));
out.println(format("public class {0} '{'", classDto.getNewClassName()));
out.println();
out.println(format(" public static final String CLASS_NAME = \"{0}\";", classDto.getOldClassName()));
out.println();
generateSimpleNames(classDto.getSimpleFields(), out);
out.println("}");

View File

@ -5,8 +5,8 @@ import java.util.List;
public class ClassSimpleDto {
private String classPackage;
private String className;
private String tableName;
private String newClassName;
private String oldClassName;
private List<SimpleFieldDto> simpleFields;
public String getClassPackage() {
@ -17,20 +17,20 @@ public class ClassSimpleDto {
this.classPackage = classPackage;
}
public String getClassName() {
return className;
public String getNewClassName() {
return newClassName;
}
public void setClassName(String className) {
this.className = className;
public void setNewClassName(String newClassName) {
this.newClassName = newClassName;
}
public String getTableName() {
return tableName;
public String getOldClassName() {
return oldClassName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
public void setOldClassName(String oldClassName) {
this.oldClassName = oldClassName;
}
public List<SimpleFieldDto> getSimpleFields() {

View File

@ -14,9 +14,7 @@ import java.util.List;
public class GeneratorSimpleMode {
public static void generate(ProcessingEnvironment processingEnv, Element annotatedElement) {
final String annotatedElementName = annotatedElement.getSimpleName().toString();
final String newClassName = annotatedElementName + Mode.SIMPLE.getDefaultPostfix();
final String oldClassName = annotatedElement.getSimpleName().toString();
final List<? extends Element> allFields = annotatedElement.getEnclosedElements().stream()
.filter(Generator::isField)
@ -26,7 +24,8 @@ public class GeneratorSimpleMode {
final List<SimpleFieldDto> simpleFields = getSimpleFields(allFields);
final ClassSimpleDto newClass = new ClassSimpleDto();
newClass.setClassName(newClassName);
newClass.setNewClassName(oldClassName + Mode.SIMPLE.getDefaultPostfix());
newClass.setOldClassName(oldClassName);
newClass.setSimpleFields(simpleFields);
newClass.setClassPackage(Generator.getPackage(annotatedElement));