Compare commits

..

4 Commits

  1. 38
      .classpath
  2. 6
      .gitignore
  3. 23
      .project
  4. 2
      pom.xml
  5. 18
      src/main/java/de/kreth/property2java/processor/Format.java
  6. 2
      src/main/java/de/kreth/property2java/processor/GenerateProperty2Java.java
  7. 3
      src/main/java/de/kreth/property2java/processor/Property2JavaGenerator.java
  8. 2
      src/main/resources/template/enum_template.tpl
  9. 5
      src/main/resources/template/enum_template_with_initializer.tpl
  10. 2
      src/main/resources/template/enum_template_with_inner_propertyresourcebundle.tpl

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

6
.gitignore vendored

@ -1,3 +1,5 @@
\.settings/
.classpath
.project
.factorypath
.settings
target

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PropertyToJavaGenerator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.kreth.property2java</groupId>
<artifactId>PropertyToJavaGenerator</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.0.3-SNAPSHOT</version>
<properties>

@ -1,9 +1,27 @@
package de.kreth.property2java.processor;
import java.util.PropertyResourceBundle;
public enum Format {
/**
* Offers a getString(UnaryOperator<String> resourceFunction) method to access
* the String value
*/
WithUnaryOperatorParameter,
/**
* Generates {@link PropertyResourceBundle} to offer a getText() method without
* parameters.
*/
WithInnerPropertyResourceBundle,
/**
* Offers a generated {@link PropertyResourceBundle} to offer a getText() method
* without parameters.
*/
WithInnerPropertyLoader,
/**
* Offers a static init(UnaryOperator<String> resourceFunction) method to offer
* a getText() method. The init method must be called before any getText() call.
*/
WithInitializer
}

@ -37,4 +37,6 @@ import java.lang.annotation.Target;
*/
public @interface GenerateProperty2Java {
String[] resources();
Format format() default Format.WithUnaryOperatorParameter;
}

@ -47,7 +47,8 @@ public class Property2JavaGenerator extends AbstractProcessor {
for (Element element : elementsAnnotatedWith) {
GenerateProperty2Java generateAnnotation = element.getAnnotation(GenerateProperty2Java.class);
String[] resources = generateAnnotation.resources();
generateElementProperties(element, Arrays.asList(resources), Format.WithUnaryOperatorParameter);
Format format = generateAnnotation.format();
generateElementProperties(element, Arrays.asList(resources), format);
}
}

@ -8,6 +8,8 @@ import javax.annotation.processing.Generated;
/**
* Property keys from ${fileName}
* {@link #getValue()} gives the key for the entry, with {@link #getString(UnaryOperator<String>)}
* the value is given directly.
*/
@Generated(date = "${generation_date}", value = "${generator_name}")
public enum ${classname} {

@ -8,6 +8,8 @@ import javax.annotation.processing.Generated;
/**
* Property keys from ${fileName}
* {@link #getValue()} gives the key for the entry, with {@link #getText()} the value for the key is given directly.
* This enum needs to be initialized before any use by {@link #init(UnaryOperator)}.
*/
@Generated(date = "${generation_date}", value = "${generator_name}")
public enum ${classname} {
@ -19,7 +21,8 @@ public enum ${classname} {
${e.constant} ("${e.key}")<#sep>,
</#sep>
</#list>;
private static UnaryOperator<String> function;
private static UnaryOperator<String> function;
private final String value;
private ${classname} (String value) {

@ -9,6 +9,8 @@ import javax.annotation.processing.Generated;
/**
* Property keys from ${fileName}
* {@link #getValue()} gives the key for the entry, with {@link #getText()} the value for the key is given directly.
* Initializationis generated also.
*/
@Generated(date = "${generation_date}", value = "${generator_name}")
public enum ${classname} {

Loading…
Cancel
Save