Compare commits
3 Commits
f83a3b235f
...
3e7c100982
Author | SHA1 | Date | |
---|---|---|---|
3e7c100982 | |||
3e720c380d | |||
8e79e74c0b |
2
pom.xml
2
pom.xml
@ -9,7 +9,7 @@
|
||||
|
||||
<groupId>dev.struchkov.haiti.utils</groupId>
|
||||
<artifactId>haiti-utils-field-constants</artifactId>
|
||||
<version>0.0.9-SNAPSHOT</version>
|
||||
<version>0.0.10-SNAPSHOT</version>
|
||||
|
||||
<name>Haiti Field Name Constants Utils</name>
|
||||
<description>Generating class field names</description>
|
||||
|
@ -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("}");
|
||||
|
@ -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() {
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user