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>
|
<groupId>dev.struchkov.haiti.utils</groupId>
|
||||||
<artifactId>haiti-utils-field-constants</artifactId>
|
<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>
|
<name>Haiti Field Name Constants Utils</name>
|
||||||
<description>Generating class field names</description>
|
<description>Generating class field names</description>
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package dev.struchkov.haiti.utils.fieldconstants.creator;
|
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.ClassSimpleDto;
|
||||||
|
import dev.struchkov.haiti.utils.fieldconstants.domain.mode.simple.SimpleFieldDto;
|
||||||
|
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
import javax.tools.JavaFileObject;
|
import javax.tools.JavaFileObject;
|
||||||
@ -27,7 +26,7 @@ public final class CreatorClassSimpleMode {
|
|||||||
public static void record(ClassSimpleDto classDto, ProcessingEnvironment environment) {
|
public static void record(ClassSimpleDto classDto, ProcessingEnvironment environment) {
|
||||||
JavaFileObject builderFile = null;
|
JavaFileObject builderFile = null;
|
||||||
try {
|
try {
|
||||||
builderFile = environment.getFiler().createSourceFile(classDto.getClassName());
|
builderFile = environment.getFiler().createSourceFile(classDto.getNewClassName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -36,8 +35,9 @@ public final class CreatorClassSimpleMode {
|
|||||||
out.println("package " + classDto.getClassPackage() + ";");
|
out.println("package " + classDto.getClassPackage() + ";");
|
||||||
out.println();
|
out.println();
|
||||||
out.println();
|
out.println();
|
||||||
out.print(format("public class {0} '{'", classDto.getClassName()));
|
out.println(format("public class {0} '{'", classDto.getNewClassName()));
|
||||||
out.println();
|
out.println();
|
||||||
|
out.println(format(" public static final String CLASS_NAME = \"{0}\";", classDto.getOldClassName()));
|
||||||
out.println();
|
out.println();
|
||||||
generateSimpleNames(classDto.getSimpleFields(), out);
|
generateSimpleNames(classDto.getSimpleFields(), out);
|
||||||
out.println("}");
|
out.println("}");
|
||||||
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||||||
public class ClassSimpleDto {
|
public class ClassSimpleDto {
|
||||||
|
|
||||||
private String classPackage;
|
private String classPackage;
|
||||||
private String className;
|
private String newClassName;
|
||||||
private String tableName;
|
private String oldClassName;
|
||||||
private List<SimpleFieldDto> simpleFields;
|
private List<SimpleFieldDto> simpleFields;
|
||||||
|
|
||||||
public String getClassPackage() {
|
public String getClassPackage() {
|
||||||
@ -17,20 +17,20 @@ public class ClassSimpleDto {
|
|||||||
this.classPackage = classPackage;
|
this.classPackage = classPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
public String getNewClassName() {
|
||||||
return className;
|
return newClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassName(String className) {
|
public void setNewClassName(String newClassName) {
|
||||||
this.className = className;
|
this.newClassName = newClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTableName() {
|
public String getOldClassName() {
|
||||||
return tableName;
|
return oldClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
public void setOldClassName(String oldClassName) {
|
||||||
this.tableName = tableName;
|
this.oldClassName = oldClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SimpleFieldDto> getSimpleFields() {
|
public List<SimpleFieldDto> getSimpleFields() {
|
||||||
|
@ -14,9 +14,7 @@ import java.util.List;
|
|||||||
public class GeneratorSimpleMode {
|
public class GeneratorSimpleMode {
|
||||||
|
|
||||||
public static void generate(ProcessingEnvironment processingEnv, Element annotatedElement) {
|
public static void generate(ProcessingEnvironment processingEnv, Element annotatedElement) {
|
||||||
final String annotatedElementName = annotatedElement.getSimpleName().toString();
|
final String oldClassName = annotatedElement.getSimpleName().toString();
|
||||||
|
|
||||||
final String newClassName = annotatedElementName + Mode.SIMPLE.getDefaultPostfix();
|
|
||||||
|
|
||||||
final List<? extends Element> allFields = annotatedElement.getEnclosedElements().stream()
|
final List<? extends Element> allFields = annotatedElement.getEnclosedElements().stream()
|
||||||
.filter(Generator::isField)
|
.filter(Generator::isField)
|
||||||
@ -26,7 +24,8 @@ public class GeneratorSimpleMode {
|
|||||||
final List<SimpleFieldDto> simpleFields = getSimpleFields(allFields);
|
final List<SimpleFieldDto> simpleFields = getSimpleFields(allFields);
|
||||||
|
|
||||||
final ClassSimpleDto newClass = new ClassSimpleDto();
|
final ClassSimpleDto newClass = new ClassSimpleDto();
|
||||||
newClass.setClassName(newClassName);
|
newClass.setNewClassName(oldClassName + Mode.SIMPLE.getDefaultPostfix());
|
||||||
|
newClass.setOldClassName(oldClassName);
|
||||||
newClass.setSimpleFields(simpleFields);
|
newClass.setSimpleFields(simpleFields);
|
||||||
newClass.setClassPackage(Generator.getPackage(annotatedElement));
|
newClass.setClassPackage(Generator.getPackage(annotatedElement));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user