Compare commits
No commits in common. '6b7bd0910689f3f5659d17d996715dda16455d23' and '67f4b40989a6d5bfe5fffe542568fc7d9876daba' have entirely different histories.
6b7bd09106
...
67f4b40989
@ -0,0 +1,38 @@ |
||||
<?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> |
||||
@ -1,5 +1,3 @@ |
||||
.classpath |
||||
.project |
||||
.factorypath |
||||
.settings |
||||
|
||||
\.settings/ |
||||
target |
||||
|
||||
@ -0,0 +1,23 @@ |
||||
<?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,27 +0,0 @@ |
||||
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 |
||||
} |
||||
@ -1,46 +0,0 @@ |
||||
package de.kreth.property2java.processor; |
||||
|
||||
import static java.lang.annotation.ElementType.TYPE; |
||||
|
||||
import java.lang.annotation.Repeatable; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
@Target(TYPE) |
||||
@Retention(RetentionPolicy.SOURCE) |
||||
@Repeatable(value = GenerateResourceBundleProperty2Javas.class) |
||||
/** |
||||
* Für die konfigurierten Resourcen wird jeweils eine Java Klasse erzeugt. Es |
||||
* muss nur die Abhängigkeit eingebunden werden und die Annotation in einer |
||||
* Klasse verwendet werden, in deren Package die neuen Klassen generiert werden. |
||||
* Wenn mehrere Resourcen verarbeitet werden sollen, kann diese Annotation |
||||
* mehrfach parallel angegeben werden. |
||||
* |
||||
* Für die Ausgabe der Prozessornachrichten muss folgendes im maven compiler |
||||
* konfiguriert werden: |
||||
* |
||||
* <pre> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>3.8.0</version> |
||||
<configuration> |
||||
<release>${java.version}</release> |
||||
<b><showWarnings>true</showWarnings></b> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
* </pre> |
||||
* |
||||
* @author Markus |
||||
* |
||||
*/ |
||||
public @interface GenerateResourceBundleProperty2Java { |
||||
String resource(); |
||||
|
||||
Format format(); |
||||
} |
||||
@ -1,21 +0,0 @@ |
||||
package de.kreth.property2java.processor; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Diese Annotation sollte nicht verwendet werden. Sie sammelt nur |
||||
* {@link GenerateResourceBundleProperty2Java} wenn diese mehrfach verwendet |
||||
* wird. |
||||
* |
||||
* @author Markus |
||||
* |
||||
*/ |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface GenerateResourceBundleProperty2Javas { |
||||
|
||||
GenerateResourceBundleProperty2Java[] value(); |
||||
} |
||||
@ -1,62 +0,0 @@ |
||||
<#if package??>package ${package}; |
||||
|
||||
</#if>import java.util.Properties; |
||||
import java.util.ResourceBundle; |
||||
import java.util.function.UnaryOperator; |
||||
|
||||
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} { |
||||
|
||||
<#list entries as e> |
||||
/** |
||||
* ${e.key} = "${e.value}" |
||||
*/ |
||||
${e.constant} ("${e.key}")<#sep>, |
||||
</#sep> |
||||
</#list>; |
||||
|
||||
private static UnaryOperator<String> function; |
||||
private final String value; |
||||
|
||||
private ${classname} (String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
public static void init(UnaryOperator<String> resourceFunction) { |
||||
function = resourceFunction; |
||||
} |
||||
|
||||
/** |
||||
* Represented Key in property File. |
||||
* @return key |
||||
*/ |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
/** |
||||
* Resolves the value for this key. |
||||
* {@link #init(UnaryOperator<String>)} must be called before. |
||||
*/ |
||||
public String getText() { |
||||
return function.apply(value); |
||||
} |
||||
|
||||
/** |
||||
* Resolves the value for this key from the parameter function. |
||||
* <p> |
||||
* e.g. <code>${classname}.getString(resBundle::getString)</code> |
||||
* @param resourceFunction {@link Properties#getProperty(String)} or {@link ResourceBundle#getString(String)} |
||||
* @return |
||||
*/ |
||||
public String getString(UnaryOperator<String> resourceFunction) { |
||||
return resourceFunction.apply(value); |
||||
} |
||||
} |
||||
@ -1,48 +0,0 @@ |
||||
<#if package??>package ${package}; |
||||
|
||||
</#if>import java.util.Properties; |
||||
import java.util.PropertyResourceBundle; |
||||
import java.util.ResourceBundle; |
||||
import java.util.function.UnaryOperator; |
||||
|
||||
import javax.annotation.processing.Generated; |
||||
|
||||
/** |
||||
* Property keys from ${fileName} |
||||
*/ |
||||
@Generated(date = "${generation_date}", value = "${generator_name}") |
||||
public enum ${classname} { |
||||
|
||||
<#list entries as e> |
||||
/** |
||||
* ${e.key} = "${e.value}" |
||||
*/ |
||||
${e.constant} ("${e.key}")<#sep>, |
||||
</#sep> |
||||
</#list>; |
||||
|
||||
private final String value; |
||||
|
||||
private ${classname} (String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
/** |
||||
* Represented Key in property File. |
||||
* @return key |
||||
*/ |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
private static ResourceBundle bundle = PropertyResourceBundle.getBundle("${bundle_base_name}"); |
||||
|
||||
/** |
||||
* The Text for this Key from PropertyResourceBundle |
||||
* @return human readable text |
||||
*/ |
||||
public String getText() { |
||||
return bundle.getString(value); |
||||
} |
||||
|
||||
} |
||||
@ -1,50 +0,0 @@ |
||||
<#if package??>package ${package}; |
||||
|
||||
</#if>import java.util.Properties; |
||||
import java.util.PropertyResourceBundle; |
||||
import java.util.ResourceBundle; |
||||
import java.util.function.UnaryOperator; |
||||
|
||||
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} { |
||||
|
||||
<#list entries as e> |
||||
/** |
||||
* ${e.key} = "${e.value}" |
||||
*/ |
||||
${e.constant} ("${e.key}")<#sep>, |
||||
</#sep> |
||||
</#list>; |
||||
|
||||
private final String value; |
||||
|
||||
private ${classname} (String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
/** |
||||
* Represented Key in property File. |
||||
* @return key |
||||
*/ |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
private static ResourceBundle bundle = PropertyResourceBundle.getBundle("${bundle_base_name}"); |
||||
|
||||
/** |
||||
* The Text for this Key from PropertyResourceBundle |
||||
* @return human readable text |
||||
*/ |
||||
public String getText() { |
||||
return bundle.getString(value); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue