Compare commits
No commits in common. '98072dcdfb7ef57dca31d91062b2c7713c60582c' and '216c3922faae3ee8bae72d2e31239c693ee221e7' have entirely different histories.
98072dcdfb
...
216c3922fa
@ -1,4 +1,4 @@ |
|||||||
package de.kreth.property2java; |
package de.kreth.property2java.processor; |
||||||
|
|
||||||
import java.util.PropertyResourceBundle; |
import java.util.PropertyResourceBundle; |
||||||
|
|
||||||
@ -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,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…
Reference in new issue