Compare commits

..

No commits in common. '98072dcdfb7ef57dca31d91062b2c7713c60582c' and '216c3922faae3ee8bae72d2e31239c693ee221e7' have entirely different histories.

  1. 1
      src/main/java/de/kreth/property2java/Configuration.java
  2. 2
      src/main/java/de/kreth/property2java/config/FreemarkerConfig.java
  3. 2
      src/main/java/de/kreth/property2java/processor/Format.java
  4. 2
      src/main/java/de/kreth/property2java/processor/GenerateProperty2Java.java
  5. 2
      src/main/java/de/kreth/property2java/processor/GenerateResourceBundleProperty2Java.java
  6. 1
      src/main/java/de/kreth/property2java/processor/ProcessorConfiguration.java
  7. 1
      src/main/java/de/kreth/property2java/processor/Property2JavaGenerator.java
  8. 16
      src/main/resources/template/enum_template.tpl
  9. 16
      src/main/resources/template/enum_template_with_initializer.tpl
  10. 38
      src/main/resources/template/enum_template_with_inner_properties.tpl
  11. 20
      src/main/resources/template/enum_template_with_inner_propertyresourcebundle.tpl
  12. 11
      src/main/resources/template/parts/enum_head_values.tpl
  13. 3
      src/main/resources/template/parts/package_part.tpl
  14. 25
      src/test/java/de/kreth/property2java/GeneratorTests.java
  15. 189
      src/test/java/de/kreth/property2java/GeneratorWithInnerPropertiesTest.java
  16. 45
      src/test/java/de/kreth/property2java/TestPropertiesSource.java
  17. 124
      src/test/java/de/kreth/property2java/generated/GenerateTheTest.java
  18. 132
      src/test/java/de/kreth/property2java/generated/Property_Loader_Properties.java
  19. 126
      src/test/java/de/kreth/property2java/generated/Resource_Bundle_Properties.java
  20. 19
      src/test/java/de/kreth/property2java/generated/TestRealGenerated.java
  21. 127
      src/test/java/de/kreth/property2java/generated/Unary_Operator_Properties.java
  22. 24
      src/test/resources/property_loader.properties
  23. 24
      src/test/resources/resource_bundle.properties
  24. 24
      src/test/resources/unary_operator.properties

@ -12,6 +12,7 @@ import java.util.Map;
import org.apache.commons.text.WordUtils;
import de.kreth.property2java.config.Regex;
import de.kreth.property2java.processor.Format;
public interface Configuration {

@ -2,7 +2,7 @@ package de.kreth.property2java.config;
import java.io.IOException;
import de.kreth.property2java.Format;
import de.kreth.property2java.processor.Format;
import freemarker.template.Configuration;
import freemarker.template.Template;

@ -1,4 +1,4 @@
package de.kreth.property2java;
package de.kreth.property2java.processor;
import java.util.PropertyResourceBundle;

@ -6,8 +6,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import de.kreth.property2java.Format;
@Target(TYPE)
@Retention(RetentionPolicy.SOURCE)
/**

@ -7,8 +7,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import de.kreth.property2java.Format;
@Target(TYPE)
@Retention(RetentionPolicy.SOURCE)
@Repeatable(value = GenerateResourceBundleProperty2Javas.class)

@ -19,7 +19,6 @@ import javax.tools.FileObject;
import javax.tools.StandardLocation;
import de.kreth.property2java.Configuration;
import de.kreth.property2java.Format;
import de.kreth.property2java.Generator;
import de.kreth.property2java.GeneratorException;

@ -16,7 +16,6 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
import de.kreth.property2java.Format;
import de.kreth.property2java.GeneratorException;
@SupportedAnnotationTypes({ "de.kreth.property2java.processor.GenerateProperty2Java",

@ -1,4 +1,6 @@
<#include "parts/package_part.tpl">import java.util.Properties;
<#if package??>package ${package};
</#if>import java.util.Properties;
import java.util.ResourceBundle;
import java.util.function.UnaryOperator;
@ -9,7 +11,17 @@ import javax.annotation.processing.Generated;
* {@link #getValue()} gives the key for the entry, with {@link #getString(UnaryOperator<String>)}
* the value is given directly.
*/
<#include "parts/enum_head_values.tpl">
@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) {

@ -1,4 +1,6 @@
<#include "parts/package_part.tpl">import java.util.Properties;
<#if package??>package ${package};
</#if>import java.util.Properties;
import java.util.ResourceBundle;
import java.util.function.UnaryOperator;
@ -9,7 +11,17 @@ import javax.annotation.processing.Generated;
* {@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)}.
*/
<#include "parts/enum_head_values.tpl">
@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;

@ -1,28 +1,32 @@
<#include "parts/package_part.tpl">import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Properties;
<#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}
*/
<#include "parts/enum_head_values.tpl">
private ${classname} (String value) {
this.value = value;
}
@Generated(date = "${generation_date}", value = "${generator_name}")
public enum ${classname} {
private static Properties properties = new Properties();
static {
try {
properties.load(${classname}.class.getResourceAsStream("/${fileName}"));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
<#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
@ -31,12 +35,14 @@ import javax.annotation.processing.Generated;
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 properties.getProperty(value);
return bundle.getString(value);
}
}

@ -1,5 +1,9 @@
<#include "parts/package_part.tpl">import java.util.PropertyResourceBundle;
<#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;
@ -8,8 +12,16 @@ import javax.annotation.processing.Generated;
* {@link #getValue()} gives the key for the entry, with {@link #getText()} the value for the key is given directly.
* Initializationis generated also.
*/
<#include "parts/enum_head_values.tpl">
private static ResourceBundle bundle = PropertyResourceBundle.getBundle("${bundle_base_name}");
@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;
@ -25,6 +37,8 @@ import javax.annotation.processing.Generated;
return value;
}
private static ResourceBundle bundle = PropertyResourceBundle.getBundle("${bundle_base_name}");
/**
* The Text for this Key from PropertyResourceBundle
* @return human readable text

@ -1,11 +0,0 @@
@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>;

@ -1,3 +0,0 @@
<#if package??>package ${package};
</#if>

@ -1,6 +1,5 @@
package de.kreth.property2java;
import static de.kreth.property2java.TestPropertiesSource.testProperties;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -14,6 +13,7 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
@ -29,6 +29,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import de.kreth.property2java.processor.Format;
class GeneratorTests {
private String path = "application.properties";
@ -43,9 +45,8 @@ class GeneratorTests {
input.put(path, testProperties());
config = Mockito.spy(TestImplConfig.class);
when(config.getRootPath()).thenReturn(new File(".").toPath());
when(config.getFormat()).thenReturn(Format.WithUnaryOperatorParameter);
when(config.getFormat()).thenReturn(Format.WithInitializer);
when(config.getInput()).thenReturn(input);
when(config.mapFilenameToClassName(anyString())).thenCallRealMethod();
when(config.outputCharset()).thenCallRealMethod();
@ -147,4 +148,22 @@ class GeneratorTests {
return line.contains("\t" + key + " ");
}
private StringReader testProperties() {
return new StringReader("\r\n" + "label = \r\n" + "\r\n" + "label.addarticle = Add Article\r\n"
+ "label.cancel = Cancel\r\n" + "label.close = Close\r\n"
+ "label.delete = Delete\r\n" + "label.discart = Discart\r\n"
+ "label.loggedin = Logged in:\r\n" + "label.logout = Logout\r\n"
+ "label.ok = OK\r\n" + "label.store = Store\r\n"
+ "label.preview = Preview\r\n" + "label.open = Open\r\n"
+ "label.user.register = Register\r\n" + "\r\n"
+ "message.article.priceerror = Please set the price.\r\n"
+ "message.delete.text = Delete {0}?\r\n"
+ "message.delete.title = Really delete?\r\n"
+ "message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \\r\\n"
+ " empty!\r\n"
+ "message.invoiceitem.startbeforeend = End must be later than start.\r\n"
+ "message.user.create.success = Thanks {0} created!\r\n"
+ "message.user.loginfailure = Login Error! Wrong user or password?\r\n"
+ "message.user.passwordmissmatch = Passwords don't match.\r\n" + "");
}
}

@ -1,189 +0,0 @@
package de.kreth.property2java;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import static de.kreth.property2java.TestPropertiesSource.testProperties;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
public class GeneratorWithInnerPropertiesTest {
private String path = "application.properties";
private Configuration config;
private Generator generator;
@BeforeEach
void setUp() throws Exception {
Map<String, Reader> input = new HashMap<>();
input.put(path, testProperties());
config = Mockito.spy(TestImplConfig.class);
when(config.getRootPath()).thenReturn(new File(".").toPath());
when(config.getFormat()).thenReturn(Format.WithInnerPropertyLoader);
when(config.getInput()).thenReturn(input);
when(config.mapFilenameToClassName(anyString())).thenCallRealMethod();
when(config.outputCharset()).thenCallRealMethod();
generator = new Generator(config);
}
@Test
void testClassDefinition() throws IOException, GeneratorException {
when(config.getPackage()).thenReturn("de.kreth.property2java");
when(config.mapFilenameToClassName(anyString())).thenCallRealMethod();
StringWriter out = new StringWriter();
when(config.outWriter(anyString())).thenReturn(out);
generator.start();
String sourceCode = out.toString().trim();
StringTokenizer sourceTokenizer = new StringTokenizer(sourceCode, "\n");
String linePackage = null;
String lineClass = null;
int countOpenBaces = 0;
int countCloseBaces = 0;
while (sourceTokenizer.hasMoreTokens()) {
String line = sourceTokenizer.nextToken();
if (line.trim().startsWith("package")) {
linePackage = line;
} else if (line.trim().startsWith("public enum")) {
lineClass = line;
}
if (line.contains("{")) {
countOpenBaces++;
}
if (line.contains("}")) {
countCloseBaces++;
}
}
assertEquals(countCloseBaces, countOpenBaces,
"Count of Braces doesn't match. Open = " + countOpenBaces + ", Close = " + countCloseBaces);
assertNotNull(linePackage);
assertNotNull(lineClass);
assertThat(linePackage,
Matchers.stringContainsInOrder(Arrays.asList("package", "de.kreth.property2java", ";")));
assertThat(lineClass,
Matchers.stringContainsInOrder(Arrays.asList("public", "enum", "Application_Properties")));
}
@Test
void testResourceLoad() throws IOException, GeneratorException {
when(config.getPackage()).thenReturn("de.kreth.property2java");
when(config.mapFilenameToClassName(anyString())).thenCallRealMethod();
StringWriter out = new StringWriter();
when(config.outWriter(anyString())).thenReturn(out);
generator.start();
String sourceCode = out.toString().trim();
StringTokenizer sourceTokenizer = new StringTokenizer(sourceCode, "\n");
String declaration = null;
String load = null;
while (sourceTokenizer.hasMoreTokens()) {
String line = sourceTokenizer.nextToken();
if (line.contains("Properties")
&& !line.contains("import")
&& !line.contains("enum")
&& !line.contains("class")) {
declaration = line;
} else if (line.contains(".load")) {
load = line;
}
}
assertNotNull(declaration);
assertNotNull(load);
assertThat(declaration,
Matchers.stringContainsInOrder(Arrays.asList("private", "static", "Properties", "properties", "=", "new Properties()", ";")));
assertThat(load,
Matchers.containsString("properties.load(Application_Properties.class.getResourceAsStream(\"/application.properties\"));"));
}
@Test
void testOneInputGeneratesOneOutput() throws IOException, GeneratorException {
Writer out = mock(Writer.class);
Writer nonOut = mock(Writer.class);
when(config.outWriter(anyString())).thenReturn(out, nonOut);
generator.start();
verify(out).close();
verify(nonOut, never()).close();
verify(nonOut, never()).flush();
}
@Test
void testKeys() throws IOException, GeneratorException {
StringWriter out = new StringWriter();
when(config.outWriter(anyString())).thenReturn(out);
generator.start();
List<String> lines = out.toString().lines().filter(line -> line.contains(" (\"")).collect(Collectors.toList());
assertEquals(21, lines.size());
assertLineMatch(lines, "label", "label");
assertLineMatch(lines, "label_addarticle", "label.addarticle");
assertLineMatch(lines, "label_user_register", "label.user.register");
assertLineMatch(lines, "message_article_priceerror", "message.article.priceerror");
assertLineMatch(lines, "message_invoiceitem_startbeforeend", "message.invoiceitem.startbeforeend");
assertLineMatch(lines, "message_invoiceitem_allfieldsmustbeset", "message.invoiceitem.allfieldsmustbeset");
}
private void assertLineMatch(List<String> lines, String key, String expected) {
Optional<String> found = lines.stream().filter(line -> keyMatches(line, key)).findFirst();
assertTrue(found.isPresent(), "No line found with key = " + key);
final String line = found.get().trim();
int indexEquals = line.indexOf('(');
String value = line.substring(indexEquals + 1).trim().substring(1);
value = value.substring(0, value.length() - 3);
assertEquals(expected, value, "Line \"" + line + "\" don't match expected Value \"" + expected + "\"");
}
private boolean keyMatches(String line, String key) {
line = line.toLowerCase();
key = key.toLowerCase();
return line.contains("\t" + key + " ");
}
}

@ -1,45 +0,0 @@
package de.kreth.property2java;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import de.kreth.property2java.generated.GenerateTheTest;
public class TestPropertiesSource {
public static StringReader testProperties() {
return new StringReader("\r\n" + "label = \r\n" + "\r\n" + "label.addarticle = Add Article\r\n"
+ "label.cancel = Cancel\r\n" + "label.close = Close\r\n"
+ "label.delete = Delete\r\n" + "label.discart = Discart\r\n"
+ "label.loggedin = Logged in:\r\n" + "label.logout = Logout\r\n"
+ "label.ok = OK\r\n" + "label.store = Store\r\n"
+ "label.preview = Preview\r\n" + "label.open = Open\r\n"
+ "label.user.register = Register\r\n" + "\r\n"
+ "message.article.priceerror = Please set the price.\r\n"
+ "message.delete.text = Delete {0}?\r\n"
+ "message.delete.title = Really delete?\r\n"
+ "message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \\r\\n"
+ " empty!\r\n"
+ "message.invoiceitem.startbeforeend = End must be later than start.\r\n"
+ "message.user.create.success = Thanks {0} created!\r\n"
+ "message.user.loginfailure = Login Error! Wrong user or password?\r\n"
+ "message.user.passwordmissmatch = Passwords don't match.\r\n" + "");
}
public static void main(String[] args) throws IOException {
File dir = new File("D:\\Markus\\programmierung\\workspace_clubhelper\\PropertyToJavaGenerator\\src\\test\\resources");
try (FileWriter out = new FileWriter(new File(dir, GenerateTheTest.PROPERTY_LOADER_PROPERTIES))) {
testProperties().transferTo(out);
}
try (FileWriter out = new FileWriter(new File(dir, GenerateTheTest.UNARY_OPERATOR_PROPERTIES))) {
testProperties().transferTo(out);
}
try (FileWriter out = new FileWriter(new File(dir, GenerateTheTest.RESOURCE_BUNDLE))) {
testProperties().transferTo(out);
}
}
}

@ -1,124 +0,0 @@
package de.kreth.property2java.generated;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import de.kreth.property2java.Configuration;
import de.kreth.property2java.Format;
import de.kreth.property2java.Generator;
import de.kreth.property2java.GeneratorException;
import de.kreth.property2java.TestPropertiesSource;
public class GenerateTheTest {
public static final String PROPERTY_LOADER_PROPERTIES = "property_loader.properties";
public static final String UNARY_OPERATOR_PROPERTIES = "unary_operator.properties";
public static final String RESOURCE_BUNDLE = "resource_bundle.properties";
public static void main(String[] args) throws IOException, GeneratorException {
Path current = Paths.get(".", "src", "test", "java", "de", "kreth", "property2java", "generated").toAbsolutePath().normalize();
System.out.println(current);
withUnaryOperatorParameter(current);
withInnerPropertyLoader(current);
withResourceBundle(current);
}
private static void withResourceBundle(Path current) throws IOException, GeneratorException {
Format format = Format.WithInnerPropertyResourceBundle;
Map<String, Reader> input = new HashMap<>();
input.put(RESOURCE_BUNDLE, TestPropertiesSource.testProperties());
Configuration config = new Configuration() {
@Override
public Path getRootPath() {
return current;
}
@Override
public String getPackage() {
return "de.kreth.property2java.generated";
}
@Override
public Format getFormat() {
return format;
}
@Override
public Map<String, Reader> getInput() {
return input;
}
};
Generator generator = new Generator(config);
generator.start();
}
private static void withUnaryOperatorParameter(Path current) throws IOException, GeneratorException {
Format format = Format.WithUnaryOperatorParameter;
Map<String, Reader> input = new HashMap<>();
input.put(UNARY_OPERATOR_PROPERTIES, TestPropertiesSource.testProperties());
Configuration config = new Configuration() {
@Override
public Path getRootPath() {
return current;
}
@Override
public String getPackage() {
return "de.kreth.property2java.generated";
}
@Override
public Format getFormat() {
return format;
}
@Override
public Map<String, Reader> getInput() {
return input;
}
};
Generator generator = new Generator(config);
generator.start();
}
private static void withInnerPropertyLoader(Path current) throws IOException, GeneratorException {
Format format = Format.WithInnerPropertyLoader;
Map<String, Reader> input = new HashMap<>();
input.put(PROPERTY_LOADER_PROPERTIES, TestPropertiesSource.testProperties());
Configuration config = new Configuration() {
@Override
public Path getRootPath() {
return current;
}
@Override
public String getPackage() {
return "de.kreth.property2java.generated";
}
@Override
public Format getFormat() {
return format;
}
@Override
public Map<String, Reader> getInput() {
return input;
}
};
Generator generator = new Generator(config);
generator.start();
}
}

@ -1,132 +0,0 @@
package de.kreth.property2java.generated;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Properties;
import javax.annotation.processing.Generated;
/**
* Property keys from property_loader.properties
*/
@Generated(date = "05.08.2024, 22:43:54", value = "de.kreth.property2java.Generator")
public enum Property_Loader_Properties {
/**
* label = ""
*/
LABEL ("label"),
/**
* label.addarticle = "Add Article"
*/
LABEL_ADDARTICLE ("label.addarticle"),
/**
* label.cancel = "Cancel"
*/
LABEL_CANCEL ("label.cancel"),
/**
* label.close = "Close"
*/
LABEL_CLOSE ("label.close"),
/**
* label.delete = "Delete"
*/
LABEL_DELETE ("label.delete"),
/**
* label.discart = "Discart"
*/
LABEL_DISCART ("label.discart"),
/**
* label.loggedin = "Logged in:"
*/
LABEL_LOGGEDIN ("label.loggedin"),
/**
* label.logout = "Logout"
*/
LABEL_LOGOUT ("label.logout"),
/**
* label.ok = "OK"
*/
LABEL_OK ("label.ok"),
/**
* label.open = "Open"
*/
LABEL_OPEN ("label.open"),
/**
* label.preview = "Preview"
*/
LABEL_PREVIEW ("label.preview"),
/**
* label.store = "Store"
*/
LABEL_STORE ("label.store"),
/**
* label.user.register = "Register"
*/
LABEL_USER_REGISTER ("label.user.register"),
/**
* message.article.priceerror = "Please set the price."
*/
MESSAGE_ARTICLE_PRICEERROR ("message.article.priceerror"),
/**
* message.delete.text = "Delete {0}?"
*/
MESSAGE_DELETE_TEXT ("message.delete.text"),
/**
* message.delete.title = "Really delete?"
*/
MESSAGE_DELETE_TITLE ("message.delete.title"),
/**
* message.invoiceitem.allfieldsmustbeset = "Start, end and article must not be
empty!"
*/
MESSAGE_INVOICEITEM_ALLFIELDSMUSTBESET ("message.invoiceitem.allfieldsmustbeset"),
/**
* message.invoiceitem.startbeforeend = "End must be later than start."
*/
MESSAGE_INVOICEITEM_STARTBEFOREEND ("message.invoiceitem.startbeforeend"),
/**
* message.user.create.success = "Thanks {0} created!"
*/
MESSAGE_USER_CREATE_SUCCESS ("message.user.create.success"),
/**
* message.user.loginfailure = "Login Error! Wrong user or password?"
*/
MESSAGE_USER_LOGINFAILURE ("message.user.loginfailure"),
/**
* message.user.passwordmissmatch = "Passwords don't match."
*/
MESSAGE_USER_PASSWORDMISSMATCH ("message.user.passwordmissmatch");
private Property_Loader_Properties (String value) {
this.value = value;
}
private static Properties properties = new Properties();
static {
try {
properties.load(Property_Loader_Properties.class.getResourceAsStream("/property_loader.properties"));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
private final String value;
/**
* Represented Key in property File.
* @return key
*/
public String getValue() {
return value;
}
/**
* The Text for this Key from PropertyResourceBundle
* @return human readable text
*/
public String getText() {
return properties.getProperty(value);
}
}

@ -1,126 +0,0 @@
package de.kreth.property2java.generated;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import javax.annotation.processing.Generated;
/**
* Property keys from resource_bundle.properties
* {@link #getValue()} gives the key for the entry, with {@link #getText()} the value for the key is given directly.
* Initializationis generated also.
*/
@Generated(date = "05.08.2024, 22:43:54", value = "de.kreth.property2java.Generator")
public enum Resource_Bundle_Properties {
/**
* label = ""
*/
LABEL ("label"),
/**
* label.addarticle = "Add Article"
*/
LABEL_ADDARTICLE ("label.addarticle"),
/**
* label.cancel = "Cancel"
*/
LABEL_CANCEL ("label.cancel"),
/**
* label.close = "Close"
*/
LABEL_CLOSE ("label.close"),
/**
* label.delete = "Delete"
*/
LABEL_DELETE ("label.delete"),
/**
* label.discart = "Discart"
*/
LABEL_DISCART ("label.discart"),
/**
* label.loggedin = "Logged in:"
*/
LABEL_LOGGEDIN ("label.loggedin"),
/**
* label.logout = "Logout"
*/
LABEL_LOGOUT ("label.logout"),
/**
* label.ok = "OK"
*/
LABEL_OK ("label.ok"),
/**
* label.open = "Open"
*/
LABEL_OPEN ("label.open"),
/**
* label.preview = "Preview"
*/
LABEL_PREVIEW ("label.preview"),
/**
* label.store = "Store"
*/
LABEL_STORE ("label.store"),
/**
* label.user.register = "Register"
*/
LABEL_USER_REGISTER ("label.user.register"),
/**
* message.article.priceerror = "Please set the price."
*/
MESSAGE_ARTICLE_PRICEERROR ("message.article.priceerror"),
/**
* message.delete.text = "Delete {0}?"
*/
MESSAGE_DELETE_TEXT ("message.delete.text"),
/**
* message.delete.title = "Really delete?"
*/
MESSAGE_DELETE_TITLE ("message.delete.title"),
/**
* message.invoiceitem.allfieldsmustbeset = "Start, end and article must not be
empty!"
*/
MESSAGE_INVOICEITEM_ALLFIELDSMUSTBESET ("message.invoiceitem.allfieldsmustbeset"),
/**
* message.invoiceitem.startbeforeend = "End must be later than start."
*/
MESSAGE_INVOICEITEM_STARTBEFOREEND ("message.invoiceitem.startbeforeend"),
/**
* message.user.create.success = "Thanks {0} created!"
*/
MESSAGE_USER_CREATE_SUCCESS ("message.user.create.success"),
/**
* message.user.loginfailure = "Login Error! Wrong user or password?"
*/
MESSAGE_USER_LOGINFAILURE ("message.user.loginfailure"),
/**
* message.user.passwordmissmatch = "Passwords don't match."
*/
MESSAGE_USER_PASSWORDMISSMATCH ("message.user.passwordmissmatch");
private static ResourceBundle bundle = PropertyResourceBundle.getBundle("resource_bundle");
private final String value;
private Resource_Bundle_Properties (String value) {
this.value = value;
}
/**
* Represented Key in property File.
* @return key
*/
public String getValue() {
return value;
}
/**
* The Text for this Key from PropertyResourceBundle
* @return human readable text
*/
public String getText() {
return bundle.getString(value);
}
}

@ -1,19 +0,0 @@
package de.kreth.property2java.generated;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class TestRealGenerated {
@Test
void propLoader() {
assertEquals("Please set the price.", Property_Loader_Properties.MESSAGE_ARTICLE_PRICEERROR.getText());
}
@Test
void resourceBundle() {
assertEquals("Login Error! Wrong user or password?", Resource_Bundle_Properties.MESSAGE_USER_LOGINFAILURE.getText());
}
}

@ -1,127 +0,0 @@
package de.kreth.property2java.generated;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.function.UnaryOperator;
import javax.annotation.processing.Generated;
/**
* Property keys from unary_operator.properties
* {@link #getValue()} gives the key for the entry, with {@link #getString(UnaryOperator<String>)}
* the value is given directly.
*/
@Generated(date = "05.08.2024, 22:43:54", value = "de.kreth.property2java.Generator")
public enum Unary_Operator_Properties {
/**
* label = ""
*/
LABEL ("label"),
/**
* label.addarticle = "Add Article"
*/
LABEL_ADDARTICLE ("label.addarticle"),
/**
* label.cancel = "Cancel"
*/
LABEL_CANCEL ("label.cancel"),
/**
* label.close = "Close"
*/
LABEL_CLOSE ("label.close"),
/**
* label.delete = "Delete"
*/
LABEL_DELETE ("label.delete"),
/**
* label.discart = "Discart"
*/
LABEL_DISCART ("label.discart"),
/**
* label.loggedin = "Logged in:"
*/
LABEL_LOGGEDIN ("label.loggedin"),
/**
* label.logout = "Logout"
*/
LABEL_LOGOUT ("label.logout"),
/**
* label.ok = "OK"
*/
LABEL_OK ("label.ok"),
/**
* label.open = "Open"
*/
LABEL_OPEN ("label.open"),
/**
* label.preview = "Preview"
*/
LABEL_PREVIEW ("label.preview"),
/**
* label.store = "Store"
*/
LABEL_STORE ("label.store"),
/**
* label.user.register = "Register"
*/
LABEL_USER_REGISTER ("label.user.register"),
/**
* message.article.priceerror = "Please set the price."
*/
MESSAGE_ARTICLE_PRICEERROR ("message.article.priceerror"),
/**
* message.delete.text = "Delete {0}?"
*/
MESSAGE_DELETE_TEXT ("message.delete.text"),
/**
* message.delete.title = "Really delete?"
*/
MESSAGE_DELETE_TITLE ("message.delete.title"),
/**
* message.invoiceitem.allfieldsmustbeset = "Start, end and article must not be
empty!"
*/
MESSAGE_INVOICEITEM_ALLFIELDSMUSTBESET ("message.invoiceitem.allfieldsmustbeset"),
/**
* message.invoiceitem.startbeforeend = "End must be later than start."
*/
MESSAGE_INVOICEITEM_STARTBEFOREEND ("message.invoiceitem.startbeforeend"),
/**
* message.user.create.success = "Thanks {0} created!"
*/
MESSAGE_USER_CREATE_SUCCESS ("message.user.create.success"),
/**
* message.user.loginfailure = "Login Error! Wrong user or password?"
*/
MESSAGE_USER_LOGINFAILURE ("message.user.loginfailure"),
/**
* message.user.passwordmissmatch = "Passwords don't match."
*/
MESSAGE_USER_PASSWORDMISSMATCH ("message.user.passwordmissmatch");
private final String value;
private Unary_Operator_Properties (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>Unary_Operator_Properties.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,24 +0,0 @@
label =
label.addarticle = Add Article
label.cancel = Cancel
label.close = Close
label.delete = Delete
label.discart = Discart
label.loggedin = Logged in:
label.logout = Logout
label.ok = OK
label.store = Store
label.preview = Preview
label.open = Open
label.user.register = Register
message.article.priceerror = Please set the price.
message.delete.text = Delete {0}?
message.delete.title = Really delete?
message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \r\n empty!
message.invoiceitem.startbeforeend = End must be later than start.
message.user.create.success = Thanks {0} created!
message.user.loginfailure = Login Error! Wrong user or password?
message.user.passwordmissmatch = Passwords don't match.

@ -1,24 +0,0 @@
label =
label.addarticle = Add Article
label.cancel = Cancel
label.close = Close
label.delete = Delete
label.discart = Discart
label.loggedin = Logged in:
label.logout = Logout
label.ok = OK
label.store = Store
label.preview = Preview
label.open = Open
label.user.register = Register
message.article.priceerror = Please set the price.
message.delete.text = Delete {0}?
message.delete.title = Really delete?
message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \r\n empty!
message.invoiceitem.startbeforeend = End must be later than start.
message.user.create.success = Thanks {0} created!
message.user.loginfailure = Login Error! Wrong user or password?
message.user.passwordmissmatch = Passwords don't match.

@ -1,24 +0,0 @@
label =
label.addarticle = Add Article
label.cancel = Cancel
label.close = Close
label.delete = Delete
label.discart = Discart
label.loggedin = Logged in:
label.logout = Logout
label.ok = OK
label.store = Store
label.preview = Preview
label.open = Open
label.user.register = Register
message.article.priceerror = Please set the price.
message.delete.text = Delete {0}?
message.delete.title = Really delete?
message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \r\n empty!
message.invoiceitem.startbeforeend = End must be later than start.
message.user.create.success = Thanks {0} created!
message.user.loginfailure = Login Error! Wrong user or password?
message.user.passwordmissmatch = Passwords don't match.
Loading…
Cancel
Save