Annotation accepts format parameter

pull/10/head
Markus Kreth 3 years ago
parent 959b7e924c
commit aab2f7b24f
  1. 23
      .project
  2. 18
      src/main/java/de/kreth/property2java/processor/Format.java
  3. 2
      src/main/java/de/kreth/property2java/processor/GenerateProperty2Java.java
  4. 3
      src/main/java/de/kreth/property2java/processor/Property2JavaGenerator.java

@ -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>

@ -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);
}
}

Loading…
Cancel
Save