You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
<#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 #getString(UnaryOperator<String>)}
|
|
* the value is given directly.
|
|
*/
|
|
@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;
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|
|
|