Compare commits
No commits in common. '4c2b2a55800b6c768192bb42e967f214c5159650' and '67f4b40989a6d5bfe5fffe542568fc7d9876daba' have entirely different histories.
4c2b2a5580
...
67f4b40989
@ -1,9 +0,0 @@ |
|||||||
package de.kreth.property2java.processor; |
|
||||||
|
|
||||||
public enum Format { |
|
||||||
|
|
||||||
WithUnaryOperatorParameter, |
|
||||||
WithInnerPropertyResourceBundle, |
|
||||||
WithInnerPropertyLoader, |
|
||||||
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,59 +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} |
|
||||||
*/ |
|
||||||
@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,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); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
Loading…
Reference in new issue