You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/12/23 17:10:26 UTC
[4/4] juneau git commit: (JUNEAU-76) Improvements to Context/Builder
APIs
(JUNEAU-76) Improvements to Context/Builder APIs
Rename PropertyStore2 to PropertyStore.
Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/b49b9192
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/b49b9192
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/b49b9192
Branch: refs/heads/master
Commit: b49b91926406ea9f2bd59253efa3768b083ad260
Parents: e2b108f
Author: JamesBognar <ja...@apache.org>
Authored: Sat Dec 23 12:10:15 2017 -0500
Committer: JamesBognar <ja...@apache.org>
Committed: Sat Dec 23 12:10:15 2017 -0500
----------------------------------------------------------------------
.../apache/juneau/ini/ConfigFileContext.java | 2 +-
.../org/apache/juneau/ContextCacheTest.java | 18 +-
.../org/apache/juneau/PropertyStore2Test.java | 198 +--
.../org/apache/juneau/XmlValidatorParser.java | 2 +-
.../juneau/XmlValidatorParserBuilder.java | 2 +-
.../apache/juneau/parser/ParserGroupTest.java | 16 +-
.../juneau/serializer/SerializerGroupTest.java | 22 +-
.../java/org/apache/juneau/jena/RdfParser.java | 20 +-
.../apache/juneau/jena/RdfParserBuilder.java | 4 +-
.../org/apache/juneau/jena/RdfSerializer.java | 24 +-
.../juneau/jena/RdfSerializerBuilder.java | 4 +-
.../java/org/apache/juneau/BeanContext.java | 2 +-
.../org/apache/juneau/BeanContextBuilder.java | 4 +-
.../main/java/org/apache/juneau/Context.java | 12 +-
.../java/org/apache/juneau/ContextBuilder.java | 6 +-
.../java/org/apache/juneau/ContextCache.java | 8 +-
.../java/org/apache/juneau/PropertyStore.java | 748 +++++++++++
.../java/org/apache/juneau/PropertyStore2.java | 748 -----------
.../org/apache/juneau/PropertyStoreBuilder.java | 22 +-
.../org/apache/juneau/PropertyStoreOld.java | 1254 ------------------
.../java/org/apache/juneau/PropertyType.java | 2 +-
.../java/org/apache/juneau/csv/CsvParser.java | 4 +-
.../org/apache/juneau/csv/CsvParserBuilder.java | 4 +-
.../org/apache/juneau/csv/CsvSerializer.java | 4 +-
.../apache/juneau/csv/CsvSerializerBuilder.java | 4 +-
.../apache/juneau/html/HtmlDocSerializer.java | 6 +-
.../java/org/apache/juneau/html/HtmlParser.java | 4 +-
.../apache/juneau/html/HtmlParserBuilder.java | 4 +-
.../juneau/html/HtmlSchemaDocSerializer.java | 4 +-
.../org/apache/juneau/html/HtmlSerializer.java | 14 +-
.../juneau/html/HtmlSerializerBuilder.java | 4 +-
.../juneau/html/HtmlStrippedDocSerializer.java | 4 +-
.../java/org/apache/juneau/jso/JsoParser.java | 4 +-
.../org/apache/juneau/jso/JsoParserBuilder.java | 4 +-
.../org/apache/juneau/jso/JsoSerializer.java | 4 +-
.../apache/juneau/jso/JsoSerializerBuilder.java | 4 +-
.../java/org/apache/juneau/json/JsonParser.java | 12 +-
.../apache/juneau/json/JsonParserBuilder.java | 4 +-
.../juneau/json/JsonSchemaSerializer.java | 2 +-
.../json/JsonSchemaSerializerBuilder.java | 4 +-
.../org/apache/juneau/json/JsonSerializer.java | 22 +-
.../juneau/json/JsonSerializerBuilder.java | 4 +-
.../apache/juneau/msgpack/MsgPackParser.java | 4 +-
.../juneau/msgpack/MsgPackParserBuilder.java | 4 +-
.../juneau/msgpack/MsgPackSerializer.java | 4 +-
.../msgpack/MsgPackSerializerBuilder.java | 4 +-
.../apache/juneau/parser/InputStreamParser.java | 2 +-
.../java/org/apache/juneau/parser/Parser.java | 4 +-
.../org/apache/juneau/parser/ParserBuilder.java | 4 +-
.../org/apache/juneau/parser/ParserGroup.java | 6 +-
.../juneau/parser/ParserGroupBuilder.java | 4 +-
.../org/apache/juneau/parser/ReaderParser.java | 2 +-
.../juneau/plaintext/PlainTextParser.java | 6 +-
.../plaintext/PlainTextParserBuilder.java | 4 +-
.../juneau/plaintext/PlainTextSerializer.java | 6 +-
.../plaintext/PlainTextSerializerBuilder.java | 4 +-
.../serializer/OutputStreamSerializer.java | 2 +-
.../apache/juneau/serializer/Serializer.java | 4 +-
.../juneau/serializer/SerializerBuilder.java | 4 +-
.../juneau/serializer/SerializerGroup.java | 6 +-
.../serializer/SerializerGroupBuilder.java | 4 +-
.../juneau/serializer/WriterSerializer.java | 2 +-
.../apache/juneau/soap/SoapXmlSerializer.java | 2 +-
.../juneau/soap/SoapXmlSerializerBuilder.java | 4 +-
.../java/org/apache/juneau/uon/UonParser.java | 10 +-
.../org/apache/juneau/uon/UonParserBuilder.java | 4 +-
.../org/apache/juneau/uon/UonSerializer.java | 14 +-
.../apache/juneau/uon/UonSerializerBuilder.java | 4 +-
.../juneau/urlencoding/UrlEncodingParser.java | 4 +-
.../urlencoding/UrlEncodingParserBuilder.java | 4 +-
.../urlencoding/UrlEncodingSerializer.java | 18 +-
.../UrlEncodingSerializerBuilder.java | 4 +-
.../org/apache/juneau/xml/XmlDocSerializer.java | 4 +-
.../java/org/apache/juneau/xml/XmlParser.java | 6 +-
.../org/apache/juneau/xml/XmlParserBuilder.java | 4 +-
.../juneau/xml/XmlSchemaDocSerializer.java | 2 +-
.../apache/juneau/xml/XmlSchemaSerializer.java | 2 +-
.../juneau/xml/XmlSchemaSerializerBuilder.java | 4 +-
.../org/apache/juneau/xml/XmlSerializer.java | 26 +-
.../apache/juneau/xml/XmlSerializerBuilder.java | 4 +-
.../apache/juneau/yaml/proto/YamlParser.java | 12 +-
.../juneau/yaml/proto/YamlParserBuilder.java | 4 +-
.../juneau/yaml/proto/YamlSerializer.java | 6 +-
.../yaml/proto/YamlSerializerBuilder.java | 4 +-
.../apache/juneau/rest/client/RestClient.java | 2 +-
.../juneau/rest/client/RestClientBuilder.java | 4 +-
.../java/org/apache/juneau/rest/RestConfig.java | 4 +-
.../org/apache/juneau/rest/RestContext.java | 4 +-
88 files changed, 1112 insertions(+), 2366 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java b/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
index 6684f0a..0484909 100644
--- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
+++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/ini/ConfigFileContext.java
@@ -24,7 +24,7 @@ public class ConfigFileContext extends Context {
*
* @param ps
*/
- public ConfigFileContext(PropertyStore2 ps) {
+ public ConfigFileContext(PropertyStore ps) {
super(ps);
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
index 4da824b..4c9ad36 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/ContextCacheTest.java
@@ -29,8 +29,8 @@ public class ContextCacheTest {
@Test
public void testBasic() {
- PropertyStoreBuilder psb = PropertyStore2.create();
- PropertyStore2 ps = psb.build();
+ PropertyStoreBuilder psb = PropertyStore.create();
+ PropertyStore ps = psb.build();
A a = ContextCache.INSTANCE.create(A.class, ps);
B b = ContextCache.INSTANCE.create(B.class, ps);
@@ -126,7 +126,7 @@ public class ContextCacheTest {
public static class A extends Context {
public final String f1;
- public A(PropertyStore2 ps) {
+ public A(PropertyStore ps) {
super(ps);
f1 = getProperty("A.f1", String.class, "xxx");
}
@@ -145,7 +145,7 @@ public class ContextCacheTest {
public static class B extends A {
public int f2;
- public B(PropertyStore2 ps) {
+ public B(PropertyStore ps) {
super(ps);
f2 = getProperty("B.f2.i", Integer.class, -1);
@@ -154,7 +154,7 @@ public class ContextCacheTest {
public static class C extends B {
public boolean f3;
- public C(PropertyStore2 ps) {
+ public C(PropertyStore ps) {
super(ps);
f3 = getProperty("C.f3.b", boolean.class, false);
}
@@ -162,8 +162,8 @@ public class ContextCacheTest {
@Test
public void testBadConstructor() {
- PropertyStoreBuilder psb = PropertyStore2.create();
- PropertyStore2 ps = psb.build();
+ PropertyStoreBuilder psb = PropertyStore.create();
+ PropertyStore ps = psb.build();
try {
ContextCache.INSTANCE.create(D1.class, ps);
@@ -180,13 +180,13 @@ public class ContextCacheTest {
}
public static class D1 extends A {
- protected D1(PropertyStore2 ps) {
+ protected D1(PropertyStore ps) {
super(ps);
}
}
public static class D2 extends A {
- public D2(PropertyStore2 ps) {
+ public D2(PropertyStore ps) {
super(ps);
throw new RuntimeException("Error!");
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/PropertyStore2Test.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/PropertyStore2Test.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/PropertyStore2Test.java
index 88f3f12..a62fa1b 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/PropertyStore2Test.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/PropertyStore2Test.java
@@ -32,7 +32,7 @@ public class PropertyStore2Test {
@Test
public void testBasic() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("B.f4.s", "4");
b.set("B.f3.s", "3");
@@ -48,7 +48,7 @@ public class PropertyStore2Test {
@Test
public void testInvalidKeys() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
testError(b, "A.f1/add", "foo", "Cannot add value 'foo' (String) to property 'f1' (String).");
testError(b, "A.f1/add.123", "foo", "Cannot add value 'foo' (String) to property 'f1' (String).");
testError(b, "A.f1/remove", "foo", "Cannot remove value 'foo' (String) from property 'f1' (String).");
@@ -63,8 +63,8 @@ public class PropertyStore2Test {
@Test
public void testString() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.s", "1");
b.set("A.f2.s", 2);
b.set("A.f3.s", true);
@@ -109,8 +109,8 @@ public class PropertyStore2Test {
@Test
public void testBoolean() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.b", "true");
b.set("A.f2.b", "false");
b.set("A.f3.b", new StringBuilder("true"));
@@ -137,8 +137,8 @@ public class PropertyStore2Test {
@Test
public void testInteger() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.i", 123);
b.set("A.f2.i", "123");
b.set("A.f3.i", new StringBuilder("123"));
@@ -166,8 +166,8 @@ public class PropertyStore2Test {
@Test
public void testClass() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.c", String.class);
b.set("A.f2.c", Integer.class);
b.set("A.f3.c", null);
@@ -189,8 +189,8 @@ public class PropertyStore2Test {
@Test
public void testObject() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.o", 123);
b.set("A.f2.o", true);
b.set("A.f3.o", new StringBuilder("123"));
@@ -222,8 +222,8 @@ public class PropertyStore2Test {
@Test
public void testSetString() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.ss", new AList<String>().appendAll("foo", "bar", "bar", null));
b.set("A.f2.ss", new AList<Object>().appendAll(123, true, TestEnum.ONE, TestEnum.ONE, null));
b.set("A.f3.ss", new AList<StringBuilder>().appendAll(new StringBuilder("foo"), null));
@@ -286,8 +286,8 @@ public class PropertyStore2Test {
@Test
public void testSetInteger() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.si", new AList<Integer>().appendAll(3, 2, 1, null));
b.set("A.f2.si", new AList<Object>().appendAll(123, "456", null));
b.set("A.f3.si", new AList<StringBuilder>().appendAll(new StringBuilder("123"), null));
@@ -380,8 +380,8 @@ public class PropertyStore2Test {
@Test
public void testSetClass() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.sc", new AList<Class<?>>().appendAll(String.class, Integer.class, null));
b.set("A.f2.sc", new AList<Object>().appendAll(String.class, Integer.class, null));
b.set("A.f3.sc", null);
@@ -446,8 +446,8 @@ public class PropertyStore2Test {
@Test
public void testListString() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.ls", new AList<String>().appendAll("foo", "bar", "bar", null));
b.set("A.f2.ls", new AList<Object>().appendAll(123, true, TestEnum.ONE, TestEnum.ONE, null));
b.set("A.f3.ls", new AList<StringBuilder>().appendAll(new StringBuilder("foo"), null));
@@ -520,8 +520,8 @@ public class PropertyStore2Test {
@Test
public void testListInteger() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.li", new AList<Integer>().appendAll(1, 2, 3, null));
b.set("A.f2.li", new AList<Object>().appendAll(123, "456", null));
b.set("A.f3.li", new AList<StringBuilder>().appendAll(new StringBuilder("123"), null));
@@ -624,8 +624,8 @@ public class PropertyStore2Test {
@Test
public void testListClass() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.lc", new AList<Class<?>>().appendAll(String.class, Integer.class, null));
b.set("A.f2.lc", new AList<Object>().appendAll(String.class, Integer.class, null));
b.set("A.f3.lc", null);
@@ -697,8 +697,8 @@ public class PropertyStore2Test {
@Test
public void testListObject() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.lo", new AList<Class<?>>().appendAll(StringBuilder.class, null));
b.set("A.f2.lo", new AList<Object>().appendAll(123, true, new StringBuilder(123), StringBuilder.class, null));
b.set("A.f3.lo", null);
@@ -770,8 +770,8 @@ public class PropertyStore2Test {
@Test
public void testMapString() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.ms", new AMap<String,String>().append("foo", "bar").append("baz", "qux").append("quux", null).append(null, null));
b.set("A.f2.ms", new AMap<String,Object>().append("foo", 123).append("bar", true).append("baz", TestEnum.ONE).append("qux", null));
b.set("A.f3.ms", new AMap<String,StringBuilder>().append("foo", new StringBuilder("bar")).append("baz", null));
@@ -811,8 +811,8 @@ public class PropertyStore2Test {
@Test
public void testMapInteger() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.mi", new AMap<String,String>().append("foo", "1").append("baz", "2").append("quux", null).append(null, null));
b.set("A.f2.mi", new AMap<String,Object>().append("foo", 123).append("bar", "456").append("baz", null));
b.set("A.f3.mi", new AMap<String,StringBuilder>().append("foo", new StringBuilder("123")).append("baz", null));
@@ -852,8 +852,8 @@ public class PropertyStore2Test {
@Test
public void testMapClass() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = null;
b.set("A.f1.mc", new AMap<String,Class<?>>().append("foo", String.class).append("baz", Integer.class).append("quux", null).append(null, null));
b.set("A.f2.mc", new AMap<String,Object>().append("foo", String.class).append("bar", Integer.class).append("baz", null));
b.set("A.f3.mc", null);
@@ -887,9 +887,9 @@ public class PropertyStore2Test {
@Test
public void testMapObject() throws Exception {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
- PropertyStore2 ps = null;
+ PropertyStore ps = null;
b.set("A.f1.mo", new AMap<String,String>().append("foo", "1").append("baz", "2").append("quux", null).append(null, null));
b.set("A.f2.mo", new AMap<String,Object>().append("foo", 123).append("bar", StringBuilder.class).append("qux", null));
b.set("A.f3.mo", new AMap<String,StringBuilder>().append("foo", new StringBuilder("123")).append("baz", null));
@@ -933,8 +933,8 @@ public class PropertyStore2Test {
@Test
public void testPropertyTypeStringHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1", "foo");
b2.set("A.f1", new StringBuilder("foo"));
@@ -960,8 +960,8 @@ public class PropertyStore2Test {
@Test
public void testPropertyTypeBooleanHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.b", true);
b2.set("A.f1.b", new StringBuilder("true"));
@@ -987,8 +987,8 @@ public class PropertyStore2Test {
@Test
public void testPropertyTypeIntegerHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.i", 1);
b2.set("A.f1.i", new StringBuilder("1"));
@@ -1016,8 +1016,8 @@ public class PropertyStore2Test {
@Test
public void testClassHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.c", String.class);
b2.set("A.f1.c", String.class);
@@ -1044,8 +1044,8 @@ public class PropertyStore2Test {
@Test
public void testObjectHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.o", "foo");
b2.set("A.f1.o", "foo");
@@ -1071,8 +1071,8 @@ public class PropertyStore2Test {
@Test
public void testSetStringHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.ss", new AList<String>().appendAll("foo", "bar"));
b2.set("A.f1.ss", new String[]{"foo","bar"});
@@ -1102,8 +1102,8 @@ public class PropertyStore2Test {
@Test
public void testSetIntegerHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.si", new AList<String>().appendAll("1", "2"));
b2.set("A.f1.si", new String[]{"1","2"});
@@ -1133,8 +1133,8 @@ public class PropertyStore2Test {
@Test
public void testSetClassHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.sc", new AList<Class<?>>().appendAll(String.class, Integer.class));
b2.set("A.f1.sc", new Class<?>[]{Integer.class,String.class});
@@ -1164,8 +1164,8 @@ public class PropertyStore2Test {
@Test
public void testListStringHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.ls", new AList<String>().appendAll("foo", "bar"));
b2.set("A.f1.ls", new String[]{"foo","bar"});
@@ -1201,8 +1201,8 @@ public class PropertyStore2Test {
@Test
public void testListIntegerHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.li", new AList<String>().appendAll("1", "2"));
b2.set("A.f1.li", new String[]{"1","2"});
@@ -1238,8 +1238,8 @@ public class PropertyStore2Test {
@Test
public void testListClassHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.lc", new AList<Class<?>>().appendAll(String.class, Integer.class));
@@ -1273,8 +1273,8 @@ public class PropertyStore2Test {
@Test
public void testListObjectHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.lo", new AList<Object>().appendAll("foo", 123, true, TestEnum.ONE));
@@ -1306,8 +1306,8 @@ public class PropertyStore2Test {
@Test
public void testMapStringHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.ms", new AMap<String,String>().append("foo", "123").append("bar", "true").append("baz", null).append(null, null));
b2.set("A.f1.ms", new AMap<String,Object>().append("foo", 123).append("bar", true).append("baz", null).append(null, null));
@@ -1337,8 +1337,8 @@ public class PropertyStore2Test {
@Test
public void testMapIntegerHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.mi", new AMap<String,Integer>().append("foo", 123).append("bar", 456).append("baz", null).append(null, null));
b2.set("A.f1.mi", new AMap<String,Object>().append("foo", 123).append("bar", "456").append("baz", null).append(null, null));
@@ -1368,8 +1368,8 @@ public class PropertyStore2Test {
@Test
public void testMapClassHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.mc", new AMap<String,Class<?>>().append("foo", String.class).append("bar", Integer.class).append("baz", null).append(null, null));
b2.set("A.f1.mc", new AMap<String,Object>().append("foo", String.class).append("bar", Integer.class).append("baz", null).append(null, null));
@@ -1400,8 +1400,8 @@ public class PropertyStore2Test {
@Test
public void testMapObjectHash() throws Exception {
- PropertyStoreBuilder b1 = PropertyStore2.create(), b2 = PropertyStore2.create();
- PropertyStore2 ps = null;
+ PropertyStoreBuilder b1 = PropertyStore.create(), b2 = PropertyStore.create();
+ PropertyStore ps = null;
b1.set("A.f1.mo", new AMap<String,TestEnum>().append("foo", TestEnum.ONE).append("bar", TestEnum.TWO).append("baz", null).append(null, null));
b2.set("A.f1.mo", new AMap<String,Object>().append("foo", TestEnum.ONE).append("bar", TestEnum.TWO).append("baz", null).append(null, null));
@@ -1436,7 +1436,7 @@ public class PropertyStore2Test {
@Test
public void testStringDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1", "foo");
assertEquals("foo", ps.getProperty("A.f1"));
@@ -1445,7 +1445,7 @@ public class PropertyStore2Test {
@Test
public void testIntegerDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.i", "1");
assertEquals(1, ps.getProperty("A.f1.i"));
@@ -1455,7 +1455,7 @@ public class PropertyStore2Test {
@Test
public void testObjectDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.o", "123");
assertEquals("123", ps.getProperty("A.f1.o"));
@@ -1465,7 +1465,7 @@ public class PropertyStore2Test {
@Test
public void testSetStringDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.ss", "['foo','bar']");
assertObjectEquals("['bar','foo']", ps.getProperty("A.f1.ss"));
@@ -1474,7 +1474,7 @@ public class PropertyStore2Test {
@Test
public void testSetIntegerDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.si", "['2','1']");
assertObjectEquals("[1,2]", ps.getProperty("A.f1.si"));
@@ -1483,7 +1483,7 @@ public class PropertyStore2Test {
@Test
public void testListStringDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.ls", "['foo','bar']");
assertObjectEquals("['foo','bar']", ps.getProperty("A.f1.ls"));
@@ -1492,7 +1492,7 @@ public class PropertyStore2Test {
@Test
public void testListIntegerDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.li", "['2','1']");
assertObjectEquals("[2,1]", ps.getProperty("A.f1.li"));
@@ -1501,7 +1501,7 @@ public class PropertyStore2Test {
@Test
public void testMapStringDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.ms", "{foo:'bar',baz:null}");
assertObjectEquals("{foo:'bar'}", ps.getProperty("A.f1.ms"));
@@ -1510,7 +1510,7 @@ public class PropertyStore2Test {
@Test
public void testMapIntegerDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.mi", "{foo:'123',baz:null}");
assertObjectEquals("{foo:123}", ps.getProperty("A.f1.mi"));
@@ -1519,7 +1519,7 @@ public class PropertyStore2Test {
@Test
public void testMapObjectDefault() {
- PropertyStore2 ps = PropertyStore2.create().build();
+ PropertyStore ps = PropertyStore.create().build();
System.setProperty("A.f1.mo", "{foo:123,bar:'baz',qux:true,quux:null}");
assertObjectEquals("{bar:'baz',foo:123,qux:true}", ps.getProperty("A.f1.mo"));
@@ -1532,17 +1532,17 @@ public class PropertyStore2Test {
@Test
public void testBuilderFromStore() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("A.foo", "bar");
- PropertyStore2 ps1 = b.build();
+ PropertyStore ps1 = b.build();
b = ps1.builder();
assertObjectEquals("{A:{foo:'bar'}}", b.build());
}
@Test
public void testSet() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set(new ObjectMap().append("A.foo", "bar"));
b.set(new ObjectMap().append("A.baz", "qux"));
b.add(null);
@@ -1551,7 +1551,7 @@ public class PropertyStore2Test {
@Test
public void testAdd() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.add(new ObjectMap().append("A.foo", "bar"));
b.add(new ObjectMap().append("A.baz", "qux"));
b.add(new ObjectMap().append("A.quux", null));
@@ -1561,21 +1561,21 @@ public class PropertyStore2Test {
@Test
public void testRemoveNotExisting() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.removeFrom("A.foo.ls", "bar");
assertObjectEquals("{}", b.build());
}
@Test
public void testAddToNull() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.addTo("A.foo.ls", null);
assertObjectEquals("{}", b.build());
}
@Test
public void testRemoveNull() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.removeFrom("A.foo.ss", null);
assertObjectEquals("{}", b.build());
b.removeFrom("A.foo.ls", null);
@@ -1584,7 +1584,7 @@ public class PropertyStore2Test {
@Test
public void testRemoveFromInvalidObjectList() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
try {
b.removeFrom("A.foo.ss", "[xxx]");
fail("Exception expected.");
@@ -1601,7 +1601,7 @@ public class PropertyStore2Test {
@Test
public void testAddToInvalidObjectMap() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
try {
b.addTo("A.foo.ms", "{xxx}");
fail("Exception expected.");
@@ -1624,16 +1624,16 @@ public class PropertyStore2Test {
@Test
public void testGetNonExistent() {
- PropertyStore2 b = PropertyStore2.create().set("A.foo", "bar").build();
+ PropertyStore b = PropertyStore.create().set("A.foo", "bar").build();
assertNull(b.getProperty("A.baz"));
assertNull(b.getProperty("B.foo"));
}
@Test
public void testHashCodes() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("A.foo", "bar").set("B.foo", "bar");
- PropertyStore2 ps = b.build();
+ PropertyStore ps = b.build();
assertEquals(ps.hashCode("A","B","C",null),ps.hashCode("A","B","C",null));
assertNotEquals(ps.hashCode("A"),ps.hashCode("B"));
@@ -1642,18 +1642,18 @@ public class PropertyStore2Test {
@Test
public void testEquals() {
- PropertyStoreBuilder b = PropertyStore2.create();
- PropertyStore2 ps = b.build();
+ PropertyStoreBuilder b = PropertyStore.create();
+ PropertyStore ps = b.build();
assertFalse(ps.equals("foo"));
}
@Test
public void testEqualsByGroups() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("A.foo", "bar").set("B.foo", "bar").set("D.foo", "bar");
- PropertyStore2 ps1 = b.build();
+ PropertyStore ps1 = b.build();
b.remove("A.foo").set("C.foo", "bar").set("D.foo", "baz");
- PropertyStore2 ps2 = b.build();
+ PropertyStore ps2 = b.build();
assertTrue(ps1.equals(ps1, null, null));
assertTrue(ps1.equals(ps2, null, null));
@@ -1668,9 +1668,9 @@ public class PropertyStore2Test {
@Test
public void testKeySet() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("A.foo", "bar").set("B.foo", "bar").set("D.foo", "bar");
- PropertyStore2 ps = b.build();
+ PropertyStore ps = b.build();
assertObjectEquals("[]", ps.getPropertyKeys(null));
assertObjectEquals("['foo']", ps.getPropertyKeys("A"));
@@ -1679,7 +1679,7 @@ public class PropertyStore2Test {
@Test
public void testToMutable() {
- PropertyStoreBuilder b = PropertyStore2.create();
+ PropertyStoreBuilder b = PropertyStore.create();
b.set("A.foo.s", "bar");
b.set("A.foo.b", true);
b.set("A.foo.i", 123);
@@ -1696,7 +1696,7 @@ public class PropertyStore2Test {
b.set("A.foo.mi", "{foo:123}");
b.set("A.foo.mc/add.foo", String.class);
b.set("A.foo.mo/add.foo", StringBuilder.class);
- PropertyStore2 ps = b.build();
+ PropertyStore ps = b.build();
b = ps.builder();
ps = b.build();
@@ -1706,7 +1706,7 @@ public class PropertyStore2Test {
@Test
public void testToString() {
- PropertyStore2 p = PropertyStore2.create().build();
+ PropertyStore p = PropertyStore.create().build();
assertEquals("{}", p.toString());
}
@@ -1730,7 +1730,7 @@ public class PropertyStore2Test {
}
private void testNotEquals(PropertyStoreBuilder b1, PropertyStoreBuilder b2) {
- PropertyStore2 p1 = b1.build(), p2 = b2.build();
+ PropertyStore p1 = b1.build(), p2 = b2.build();
assertTrue(p1 != p2);
assertTrue(p1.hashCode() != p2.hashCode());
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
index 7703ddb..14073cc 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
@@ -30,7 +30,7 @@ import org.apache.juneau.xml.*;
public class XmlValidatorParser extends XmlParser {
public XmlValidatorParser() {
- super(PropertyStore2.DEFAULT);
+ super(PropertyStore.DEFAULT);
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParserBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParserBuilder.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParserBuilder.java
index 8c68e7c..1a2d799 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParserBuilder.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParserBuilder.java
@@ -17,7 +17,7 @@ import org.apache.juneau.xml.*;
public class XmlValidatorParserBuilder extends XmlParserBuilder {
public XmlValidatorParserBuilder() {
- super(PropertyStore2.DEFAULT);
+ super(PropertyStore.DEFAULT);
}
@Override
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
index a984635..f3e726b 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
@@ -46,19 +46,19 @@ public class ParserGroupTest {
public static class Parser1 extends JsonParser {
- public Parser1(PropertyStore2 ps) {
+ public Parser1(PropertyStore ps) {
super(ps, "text/foo", "text/foo_a");
}
}
public static class Parser2 extends JsonParser {
- public Parser2(PropertyStore2 ps) {
+ public Parser2(PropertyStore ps) {
super(ps, "text/foo+bar", "text/foo+bar_a");
}
}
public static class Parser3 extends JsonParser {
- public Parser3(PropertyStore2 ps) {
+ public Parser3(PropertyStore ps) {
super(ps, "text/baz", "text/baz_a");
}
}
@@ -85,31 +85,31 @@ public class ParserGroupTest {
}
public static class P1 extends JsonParser {
- public P1(PropertyStore2 ps) {
+ public P1(PropertyStore ps) {
super(ps, "text/1");
}
}
public static class P2 extends JsonParser {
- public P2(PropertyStore2 ps) {
+ public P2(PropertyStore ps) {
super(ps, "text/2", "text/2a");
}
}
public static class P3 extends JsonParser {
- public P3(PropertyStore2 ps) {
+ public P3(PropertyStore ps) {
super(ps, "text/3");
}
}
public static class P4 extends JsonParser {
- public P4(PropertyStore2 ps) {
+ public P4(PropertyStore ps) {
super(ps, "text/4", "text/4a");
}
}
public static class P5 extends JsonParser {
- public P5(PropertyStore2 ps) {
+ public P5(PropertyStore ps) {
super(ps, "text/5");
}
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
index 45f3383..0fb0c5d 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
@@ -51,19 +51,19 @@ public class SerializerGroupTest {
public static class SA1 extends JsonSerializer {
- public SA1(PropertyStore2 ps) {
+ public SA1(PropertyStore ps) {
super(ps, "application/json", "text/foo+*", "text/foo_a+*");
}
}
public static class SA2 extends JsonSerializer {
- public SA2(PropertyStore2 ps) {
+ public SA2(PropertyStore ps) {
super(ps, "application/json", "text/foo+bar+*", "text/foo+bar_a+*");
}
}
public static class SA3 extends JsonSerializer {
- public SA3(PropertyStore2 ps) {
+ public SA3(PropertyStore ps) {
super(ps, "application/json", "text/baz+*", "text/baz_a+*");
}
}
@@ -90,31 +90,31 @@ public class SerializerGroupTest {
}
public static class SB1 extends JsonSerializer {
- public SB1(PropertyStore2 ps) {
+ public SB1(PropertyStore ps) {
super(ps, "application/json", "text/1");
}
}
public static class SB2 extends JsonSerializer {
- public SB2(PropertyStore2 ps) {
+ public SB2(PropertyStore ps) {
super(ps, "application/json", "text/2", "text/2a");
}
}
public static class SB3 extends JsonSerializer {
- public SB3(PropertyStore2 ps) {
+ public SB3(PropertyStore ps) {
super(ps, "application/json", "text/3");
}
}
public static class SB4 extends JsonSerializer {
- public SB4(PropertyStore2 ps) {
+ public SB4(PropertyStore ps) {
super(ps, "application/json", "text/4", "text/4a");
}
}
public static class SB5 extends JsonSerializer {
- public SB5(PropertyStore2 ps) {
+ public SB5(PropertyStore ps) {
super(ps, "application/json", "text/5");
}
}
@@ -135,19 +135,19 @@ public class SerializerGroupTest {
}
public static class SC1 extends JsonSerializer {
- public SC1(PropertyStore2 ps) {
+ public SC1(PropertyStore ps) {
super(ps, "application/json", "text/*");
}
}
public static class SC2 extends JsonSerializer {
- public SC2(PropertyStore2 ps) {
+ public SC2(PropertyStore ps) {
super(ps, "application/json", "*/json");
}
}
public static class SC3 extends JsonSerializer {
- public SC3(PropertyStore2 ps) {
+ public SC3(PropertyStore ps) {
super(ps, "application/json", "*/*");
}
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
index bbe95d4..a7217ca 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
@@ -74,16 +74,16 @@ public class RdfParser extends ReaderParser implements RdfCommon {
//-------------------------------------------------------------------------------------------------------------------
/** Default XML parser, all default settings.*/
- public static final RdfParser DEFAULT_XML = new Xml(PropertyStore2.DEFAULT);
+ public static final RdfParser DEFAULT_XML = new Xml(PropertyStore.DEFAULT);
/** Default Turtle parser, all default settings.*/
- public static final RdfParser DEFAULT_TURTLE = new Turtle(PropertyStore2.DEFAULT);
+ public static final RdfParser DEFAULT_TURTLE = new Turtle(PropertyStore.DEFAULT);
/** Default N-Triple parser, all default settings.*/
- public static final RdfParser DEFAULT_NTRIPLE = new NTriple(PropertyStore2.DEFAULT);
+ public static final RdfParser DEFAULT_NTRIPLE = new NTriple(PropertyStore.DEFAULT);
/** Default N3 parser, all default settings.*/
- public static final RdfParser DEFAULT_N3 = new N3(PropertyStore2.DEFAULT);
+ public static final RdfParser DEFAULT_N3 = new N3(PropertyStore.DEFAULT);
//-------------------------------------------------------------------------------------------------------------------
@@ -98,7 +98,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public Xml(PropertyStore2 ps) {
+ public Xml(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_RDF_XML)
@@ -116,7 +116,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public NTriple(PropertyStore2 ps) {
+ public NTriple(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_NTRIPLE)
@@ -134,7 +134,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public Turtle(PropertyStore2 ps) {
+ public Turtle(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_TURTLE)
@@ -152,7 +152,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public N3(PropertyStore2 ps) {
+ public N3(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_N3)
@@ -178,7 +178,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
* @param ps The property store containing all the settings for this object.
* @param consumes The list of media types that this parser consumes (e.g. <js>"application/json"</js>).
*/
- public RdfParser(PropertyStore2 ps, String...consumes) {
+ public RdfParser(PropertyStore ps, String...consumes) {
super(ps, consumes);
trimWhitespace = getProperty(RDF_trimWhitespace, boolean.class, false);
looseCollections = getProperty(RDF_looseCollections, boolean.class, false);
@@ -193,7 +193,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public RdfParser(PropertyStore2 ps) {
+ public RdfParser(PropertyStore ps) {
this(ps, "text/xml+rdf");
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
index 87d830f..a126b9a 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
@@ -41,7 +41,7 @@ public class RdfParserBuilder extends ParserBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public RdfParserBuilder(PropertyStore2 ps) {
+ public RdfParserBuilder(PropertyStore ps) {
super(ps);
}
@@ -710,7 +710,7 @@ public class RdfParserBuilder extends ParserBuilder {
}
@Override /* ContextBuilder */
- public RdfParserBuilder apply(PropertyStore2 copyFrom) {
+ public RdfParserBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
index 0f4d042..aee78d6 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
@@ -146,19 +146,19 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
//-------------------------------------------------------------------------------------------------------------------
/** Default RDF/XML serializer, all default settings.*/
- public static final RdfSerializer DEFAULT_XML = new Xml(PropertyStore2.DEFAULT);
+ public static final RdfSerializer DEFAULT_XML = new Xml(PropertyStore.DEFAULT);
/** Default Abbreviated RDF/XML serializer, all default settings.*/
- public static final RdfSerializer DEFAULT_XMLABBREV = new XmlAbbrev(PropertyStore2.DEFAULT);
+ public static final RdfSerializer DEFAULT_XMLABBREV = new XmlAbbrev(PropertyStore.DEFAULT);
/** Default Turtle serializer, all default settings.*/
- public static final RdfSerializer DEFAULT_TURTLE = new Turtle(PropertyStore2.DEFAULT);
+ public static final RdfSerializer DEFAULT_TURTLE = new Turtle(PropertyStore.DEFAULT);
/** Default N-Triple serializer, all default settings.*/
- public static final RdfSerializer DEFAULT_NTRIPLE = new NTriple(PropertyStore2.DEFAULT);
+ public static final RdfSerializer DEFAULT_NTRIPLE = new NTriple(PropertyStore.DEFAULT);
/** Default N3 serializer, all default settings.*/
- public static final RdfSerializer DEFAULT_N3 = new N3(PropertyStore2.DEFAULT);
+ public static final RdfSerializer DEFAULT_N3 = new N3(PropertyStore.DEFAULT);
//-------------------------------------------------------------------------------------------------------------------
@@ -173,7 +173,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public Xml(PropertyStore2 ps) {
+ public Xml(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_RDF_XML)
@@ -191,7 +191,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public XmlAbbrev(PropertyStore2 ps) {
+ public XmlAbbrev(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_RDF_XML_ABBREV)
@@ -210,7 +210,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public NTriple(PropertyStore2 ps) {
+ public NTriple(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_NTRIPLE)
@@ -228,7 +228,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public Turtle(PropertyStore2 ps) {
+ public Turtle(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_TURTLE)
@@ -246,7 +246,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*
* @param ps The property store containing all the settings for this object.
*/
- public N3(PropertyStore2 ps) {
+ public N3(PropertyStore ps) {
super(
ps.builder()
.set(RDF_language, LANG_N3)
@@ -296,7 +296,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
* <br>...or...
* <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*​/json"</js>);</code>
*/
- public RdfSerializer(PropertyStore2 ps, String produces, String...accept) {
+ public RdfSerializer(PropertyStore ps, String produces, String...accept) {
super(ps, produces, accept);
addLiteralTypes = getProperty(RDF_addLiteralTypes, boolean.class, false);
addRootProperty = getProperty(RDF_addRootProperty, boolean.class, false);
@@ -323,7 +323,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
* @param ps
* The property store containing all the settings for this object.
*/
- public RdfSerializer(PropertyStore2 ps) {
+ public RdfSerializer(PropertyStore ps) {
this(ps, "text/xml+rdf");
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
index 25e7a81..6ccde5f 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
@@ -41,7 +41,7 @@ public class RdfSerializerBuilder extends SerializerBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public RdfSerializerBuilder(PropertyStore2 ps) {
+ public RdfSerializerBuilder(PropertyStore ps) {
super(ps);
}
@@ -902,7 +902,7 @@ public class RdfSerializerBuilder extends SerializerBuilder {
}
@Override /* ContextBuilder */
- public RdfSerializerBuilder apply(PropertyStore2 copyFrom) {
+ public RdfSerializerBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index b959961..a002ff7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -955,7 +955,7 @@ public class BeanContext extends Context {
*
* @param ps The property store containing the unmodifiable configuration for this bean context.
*/
- public BeanContext(PropertyStore2 ps) {
+ public BeanContext(PropertyStore ps) {
super(ps);
hashCode = ps.hashCode("BeanContext");
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
index 86680d9..5b19d6e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
@@ -43,7 +43,7 @@ public class BeanContextBuilder extends ContextBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public BeanContextBuilder(PropertyStore2 ps) {
+ public BeanContextBuilder(PropertyStore ps) {
super(ps);
}
@@ -1272,7 +1272,7 @@ public class BeanContextBuilder extends ContextBuilder {
}
@Override /* ContextBuilder */
- public BeanContextBuilder apply(PropertyStore2 copyFrom) {
+ public BeanContextBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
index 9fa193f..06178c3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
@@ -26,16 +26,16 @@ import org.apache.juneau.serializer.*;
* Contexts are created through the {@link ContextBuilder#build()} method.
*
* <p>
- * Subclasses MUST implement a constructor method that takes in a {@link PropertyStore2} parameter.
+ * Subclasses MUST implement a constructor method that takes in a {@link PropertyStore} parameter.
* Besides that restriction, a context object can do anything you desire.
* However, it MUST be thread-safe and all fields should be declared final to prevent modification.
* It should NOT be used for storing temporary or state information.
*
- * @see PropertyStore2
+ * @see PropertyStore
*/
public abstract class Context {
- private final PropertyStore2 propertyStore;
+ private final PropertyStore propertyStore;
/**
* Constructor for this class.
@@ -45,8 +45,8 @@ public abstract class Context {
*
* @param ps The read-only configuration for this context object.
*/
- public Context(PropertyStore2 ps) {
- this.propertyStore = ps == null ? PropertyStore2.DEFAULT : ps;
+ public Context(PropertyStore ps) {
+ this.propertyStore = ps == null ? PropertyStore.DEFAULT : ps;
}
/**
@@ -279,7 +279,7 @@ public abstract class Context {
* @return The property store associated with this context.
*/
@BeanIgnore
- public final PropertyStore2 getPropertyStore() {
+ public final PropertyStore getPropertyStore() {
return propertyStore;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
index 5616cdd..3be7636 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
@@ -27,7 +27,7 @@ public abstract class ContextBuilder {
* Default settings.
*/
public ContextBuilder() {
- this.psb = PropertyStore2.create();
+ this.psb = PropertyStore.create();
}
/**
@@ -35,7 +35,7 @@ public abstract class ContextBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public ContextBuilder(PropertyStore2 ps) {
+ public ContextBuilder(PropertyStore ps) {
this.psb = ps.builder();
}
@@ -53,7 +53,7 @@ public abstract class ContextBuilder {
* @param copyFrom The factory whose settings are being copied.
* @return This object (for method chaining).
*/
- public ContextBuilder apply(PropertyStore2 copyFrom) {
+ public ContextBuilder apply(PropertyStore copyFrom) {
this.psb.apply(copyFrom);
return this;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextCache.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextCache.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextCache.java
index 7fae9bf..6784111 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextCache.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextCache.java
@@ -96,7 +96,7 @@ public class ContextCache {
* @param ps The property store to use to create the class.
* @return The
*/
- public <T extends Context> T create(Class<T> c, PropertyStore2 ps) {
+ public <T extends Context> T create(Class<T> c, PropertyStore ps) {
ConcurrentHashMap<Integer,CacheEntry> m = getContextCache(c);
String[] prefixes = getPrefixes(c);
@@ -151,7 +151,7 @@ public class ContextCache {
Constructor<?> c = constructorCache.get(cc);
if (c == null) {
try {
- c = cc.getConstructor(PropertyStore2.class);
+ c = cc.getConstructor(PropertyStore.class);
} catch (NoSuchMethodException e) {
throw new ContextRuntimeException(e, "Public constructor with PropertyStore argument not found on class ''{0}''", cc);
}
@@ -163,10 +163,10 @@ public class ContextCache {
}
private static class CacheEntry {
- final PropertyStore2 ps;
+ final PropertyStore ps;
final Context context;
- CacheEntry(PropertyStore2 ps, Context context) {
+ CacheEntry(PropertyStore ps, Context context) {
this.ps = ps;
this.context = context;
}
http://git-wip-us.apache.org/repos/asf/juneau/blob/b49b9192/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
new file mode 100644
index 0000000..a6971a9
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
@@ -0,0 +1,748 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau;
+
+import static org.apache.juneau.PropertyType.*;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import org.apache.juneau.PropertyStoreBuilder.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.serializer.*;
+
+
+/**
+ * Represents an immutable collection of properties.
+ *
+ * <p>
+ * The general idea behind a property store is to serve as a reusable configuration of an artifact (e.g. a Serializer)
+ * such that the artifact can be cached and reused if the property stores are 'equal'.
+ *
+ * <p>
+ * For example, two serializers of the same type created with the same configuration will always end up being
+ * the same serializer:
+ *
+ * <p class='bcode'>
+ * WriterSerializer s1 = JsonSerializer.<jsm>create</jsm>().pojoSwaps(MySwap.<jk>class</jk>).simple().build();
+ * WriterSerializer s2 = JsonSerializer.<jsm>create</jsm>().simple().pojoSwaps(MySwap.<jk>class</jk>).build();
+ * <jk>assert</jk>(s1 == s2);
+ * </p>
+ *
+ * <p>
+ * This has the effect of significantly improving performance, especially if you're creating many Serializers and
+ * Parsers.
+ *
+ * <p>
+ * Property names must have the following format...
+ * <p class='bcode'>
+ * <js>"{group}.{name}.{type}"</js>
+ * </p>
+ * ...where the parts consist of the following...
+ * <ul>
+ * <li><js>"{group}"</js> - The group name of the property (e.g. <js>"JsonSerializer"</js>).
+ * <br>It's always going to be the simple class name of the class it's associated with.
+ * <li><js>"{name}"</js> - The property name (e.g. <js>"useWhitespace"</js>).
+ * <li><js>"{type}"</js> - The property data type.
+ * <br>A 1 or 2 character string that identifies the data type of the property.
+ * <br>Valid values are:
+ * <ul>
+ * <li><js>"s"<js>: <code>String</code>
+ * <li><js>"b"<js>: <code>Boolean</code>
+ * <li><js>"i"<js>: <code>Integer</code>
+ * <li><js>"c"<js>: <code>Class</code>
+ * <li><js>"o"<js>: <code>Object</code>
+ * <li><js>"ss"<js>: <code>TreeSet<String></code>
+ * <li><js>"si"<js>: <code>TreeSet<Integer></code>
+ * <li><js>"sc"<js>: <code>TreeSet<Class></code>
+ * <li><js>"ls"<js>: <code>ArrayList<String></code>
+ * <li><js>"li"<js>: <code>ArrayList<Integer></code>
+ * <li><js>"lc"<js>: <code>ArrayList<Class></code>
+ * <li><js>"lo"<js>: <code>ArrayList<Object></code>
+ * <li><js>"ms"<js>: <code>TreeMap<String,String></code>
+ * <li><js>"mi"<js>: <code>TreeMap<String,Integer></code>
+ * <li><js>"mc"<js>: <code>TreeMap<String,Class></code>
+ * <li><js>"mo"<js>: <code>TreeMap<String,Object></code>
+ * </ul>
+ * </ul>
+ *
+ * <p>
+ * For example, the {@link JsonSerializer} extends from {@link Serializer} and {@link BeanContext}, and therefore
+ * is configured by properties defined in the <js>"JsonSerializer"</js>, <js>"Serializer"</js>, and <js>"BeanContext"</js>
+ * groups. Since serializers and bean contexts can be relatively expensive to instantiate, we can cache and
+ * reuse <code>JsonSerializer</code> instances if the property store used to instantiate them have equivalent
+ * <js>"JsonSerializer"</js>, <js>"Serializer"</js>, and <js>"BeanContext"</js> groups.
+ *
+ * <p>
+ * Set and list properties have the additional convenience 'command' names for adding and removing entries:
+ * <p class='bcode'>
+ * <js>"{group}.{name}.{type}/add"</js> <jc>// Add a value to the set/list.</jc>
+ * <js>"{group}.{name}.{type}/remove"</js> <jc>// Remove a value from the set/list.</jc>
+ * </p>
+ *
+ * <p>
+ * Set properties are typically used in cases where the order of the value is not important.
+ * A <code>TreeSet</code> is used so that the order in which you add elements does not affect the resulting order
+ * of the property.
+ *
+ * <p>
+ * List properties are typically used in cases where the order in which entries are added is important.
+ * Adding to a list property will cause the new entries to be added to the BEGINNING of the list.
+ * This ensures that the resulting order of the list is in most-to-least importance.
+ * For example, multiple calls to <code>pojoSwaps()</code> causes new entries to be added to the beginning of the list
+ * so that previous values can be 'overridden':
+ * <p class='bcode'>
+ * <jc>// Swap order: [MySwap2.class, MySwap1.class]</jc>
+ * JsonSerializer.create().pojoSwaps(MySwap1.class).pojoSwaps(MySwap2.class).build();
+ * </p>
+ * <p>
+ * Note that the order is different when passing multiple values into the <code>pojoSwaps()</code> method, in which
+ * case the order should be first-match-wins:
+ * <p class='bcode'>
+ * <jc>// Swap order: [MySwap1.class, MySwap2.class]</jc>
+ * JsonSerializer.create().pojoSwaps(MySwap1.class,MySwap2.class).build();
+ * </p>
+ *
+ * <p>
+ * Map properties have the additional convenience property name for adding and removing map entries:
+ * <p class='bcode'>
+ * <js>"{group}.{name}.{type}/add.{key}"</js> <jc>// Add a map entry (or delete if the value is null).</jc>
+ * </p>
+ *
+ * <p>
+ * Property stores are entirely immutable which means their hashcode is calculated exactly once, meaning they
+ * are particularly good for use as hashmap keys.
+ */
+@SuppressWarnings("unchecked")
+public final class PropertyStore {
+
+ /**
+ * A default empty property store.
+ */
+ public static PropertyStore DEFAULT = PropertyStore.create().build();
+
+ final SortedMap<String,PropertyGroup> groups;
+ private final int hashCode;
+
+ // Created by PropertyStoreBuilder.build()
+ PropertyStore(Map<String,PropertyGroupBuilder> propertyMaps) {
+ TreeMap<String,PropertyGroup> m = new TreeMap<>();
+ for (Map.Entry<String,PropertyGroupBuilder> p : propertyMaps.entrySet())
+ m.put(p.getKey(), p.getValue().build());
+ this.groups = Collections.unmodifiableSortedMap(m);
+ this.hashCode = groups.hashCode();
+ }
+
+ /**
+ * Creates a new empty builder for a property store.
+ *
+ * @return A new empty builder for a property store.
+ */
+ public static PropertyStoreBuilder create() {
+ return new PropertyStoreBuilder();
+ }
+
+ /**
+ * Creates a new property store builder initialized with the values in this property store.
+ *
+ * @return A new property store builder.
+ */
+ public PropertyStoreBuilder builder() {
+ return new PropertyStoreBuilder(this);
+ }
+
+ private Property findProperty(String key) {
+ String g = group(key);
+ String k = key.substring(g.length()+1);
+ PropertyGroup pm = groups.get(g);
+
+ if (pm != null) {
+ Property p = pm.get(k);
+ if (p != null)
+ return p;
+ }
+
+ String s = System.getProperty(key);
+ if (s != null)
+ return PropertyStoreBuilder.MutableProperty.create(k, s).build();
+
+ return null;
+ }
+
+ /**
+ * Returns the raw property value with the specified name.
+ *
+ * @param key The property name.
+ * @return The property value, or <jk>null</jk> if it doesn't exist.
+ */
+ public Object getProperty(String key) {
+ Property p = findProperty(key);
+ return p == null ? null : p.value;
+ }
+
+ /**
+ * Returns the property value with the specified name.
+ *
+ * @param key The property name.
+ * @param c The class to cast or convert the value to.
+ * @param def The default value.
+ * @return The property value, or the default value if it doesn't exist.
+ */
+ public <T> T getProperty(String key, Class<T> c, T def) {
+ Property p = findProperty(key);
+ return p == null ? def : p.as(c);
+ }
+
+ /**
+ * Returns the class property with the specified name.
+ *
+ * @param key The property name.
+ * @param type The class type of the property.
+ * @param def The default value.
+ * @return The property value, or the default value if it doesn't exist.
+ */
+ public <T> Class<? extends T> getClassProperty(String key, Class<T> type, Class<? extends T> def) {
+ Property p = findProperty(key);
+ return p == null ? def : (Class<T>)p.as(Class.class);
+ }
+
+ /**
+ * Returns the array property value with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value, or an empty array if it doesn't exist.
+ */
+ public <T> T[] getArrayProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return (T[]) (p == null ? Array.newInstance(eType, 0) : p.asArray(eType));
+ }
+
+ /**
+ * Returns the array property value with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @param def The default value.
+ * @return The property value, or an empty array if it doesn't exist.
+ */
+ public <T> T[] getArrayProperty(String key, Class<T> eType, T[] def) {
+ Property p = findProperty(key);
+ return p == null ? def : p.asArray(eType);
+ }
+
+ /**
+ * Returns the class array property with the specified name.
+ *
+ * @param key The property name.
+ * @return The property value, or an empty array if it doesn't exist.
+ */
+ public Class<?>[] getClassArrayProperty(String key) {
+ Property p = findProperty(key);
+ return p == null ? new Class[0] : p.as(Class[].class);
+ }
+
+ /**
+ * Returns the class array property with the specified name.
+ *
+ * @param key The property name.
+ * @param def The default value.
+ * @return The property value, or an empty array if it doesn't exist.
+ */
+ public Class<?>[] getClassArrayProperty(String key, Class<?>[] def) {
+ Property p = findProperty(key);
+ return p == null ? def : p.as(Class[].class);
+ }
+
+ /**
+ * Returns the class array property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value, or an empty array if it doesn't exist.
+ */
+ public <T> Class<T>[] getClassArrayProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? new Class[0] : p.as(Class[].class);
+ }
+
+ /**
+ * Returns the set property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>LinkedHashSet</code>, or an empty set if it doesn't exist.
+ */
+ public <T> Set<T> getSetProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_SET : p.asSet(eType);
+ }
+
+ /**
+ * Returns the class set property with the specified name.
+ *
+ * @param key The property name.
+ * @return The property value as an unmodifiable <code>LinkedHashSet</code>, or an empty set if it doesn't exist.
+ */
+ public Set<Class<?>> getClassSetProperty(String key) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_SET : p.asSet(Class.class);
+ }
+
+ /**
+ * Returns the class set property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>LinkedHashSet</code>, or an empty set if it doesn't exist.
+ */
+ public <T> Set<Class<T>> getClassSetProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_SET : p.asSet(Class.class);
+ }
+
+ /**
+ * Returns the list property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>ArrayList</code>, or an empty list if it doesn't exist.
+ */
+ public <T> List<T> getListProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_LIST : p.asList(eType);
+ }
+
+ /**
+ * Returns the class list property with the specified name.
+ *
+ * @param key The property name.
+ * @return The property value as an unmodifiable <code>ArrayList</code>, or an empty list if it doesn't exist.
+ */
+ public List<Class<?>> getClassListProperty(String key) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_LIST : p.asList(Class.class);
+ }
+
+ /**
+ * Returns the class list property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>ArrayList</code>, or an empty list if it doesn't exist.
+ */
+ public <T> List<Class<T>> getClassListProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_LIST : p.asList(Class.class);
+ }
+
+ /**
+ * Returns the map property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>LinkedHashMap</code>, or an empty map if it doesn't exist.
+ */
+ public <T> Map<String,T> getMapProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_MAP : p.asMap(eType);
+ }
+
+ /**
+ * Returns the class map property with the specified name.
+ *
+ * @param key The property name.
+ * @return The property value as an unmodifiable <code>LinkedHashMap</code>, or an empty map if it doesn't exist.
+ */
+ public Map<String,Class<?>> getClassMapProperty(String key) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_MAP : p.asMap(Class.class);
+ }
+
+ /**
+ * Returns the class map property with the specified name.
+ *
+ * @param key The property name.
+ * @param eType The class type of the elements in the property.
+ * @return The property value as an unmodifiable <code>LinkedHashMap</code>, or an empty map if it doesn't exist.
+ */
+ public <T> Map<String,Class<T>> getClassMapProperty(String key, Class<T> eType) {
+ Property p = findProperty(key);
+ return p == null ? Collections.EMPTY_MAP : p.asMap(Class.class);
+ }
+
+ /**
+ * Returns an instance of the specified class or string property.
+ *
+ * @param key The property name.
+ * @param type The class type of the property.
+ * @param def
+ * The default value if the property doesn't exist.
+ * <br>Can either be an instance of <code>T</code>, or a <code>Class<? <jk>extends</jk> T></code>.
+ * @return A new property instance.
+ */
+ public <T> T getInstanceProperty(String key, Class<T> type, Object def) {
+ Property p = findProperty(key);
+ if (p != null)
+ return p.asInstance(type);
+ if (def == null)
+ return null;
+ if (def instanceof Class) {
+ T t = ClassUtils.newInstance(type, def);
+ if (t != null)
+ return t;
+ }
+ if (type.isInstance(def))
+ return (T)def;
+ throw new ConfigException("Could not instantiate property ''{0}'' as type ''{1}'' with default value ''{2}''", key, type, def);
+ }
+
+ /**
+ * Returns the specified property as an array of instantiated objects.
+ *
+ * @param key The property name.
+ * @param type The class type of the property.
+ * @param def The default object to return if the property doesn't exist.
+ * @return A new property instance.
+ */
+ public <T> T[] getInstanceArrayProperty(String key, Class<T> type, T[] def) {
+ Property p = findProperty(key);
+ return p == null ? def : p.asInstanceArray(type);
+ }
+
+ /**
+ * Returns the keys found in the specified property group.
+ *
+ * <p>
+ * The keys are NOT prefixed with group names.
+ *
+ * @param group The group name.
+ * @return The set of property keys, or an empty set if the group was not found.
+ */
+ public Set<String> getPropertyKeys(String group) {
+ if (group == null)
+ return Collections.EMPTY_SET;
+ PropertyGroup g = groups.get(group);
+ return g == null ? Collections.EMPTY_SET : g.keySet();
+ }
+
+ @Override /* Object */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ /**
+ * Returns a hashcode of this property store using only the specified group names.
+ *
+ * @param groups The names of the property groups to use in the calculation.
+ * @return The hashcode.
+ */
+ public Integer hashCode(String...groups) {
+ HashCode c = new HashCode();
+ for (String p : groups)
+ if (p != null)
+ c.add(p).add(this.groups.get(p));
+ return c.get();
+ }
+
+ @Override /* Object */
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o instanceof PropertyStore)
+ return (this.groups.equals(((PropertyStore)o).groups));
+ return false;
+ }
+
+ /**
+ * Compares two property stores, but only based on the specified group names.
+ *
+ * @param ps The property store to compare to.
+ * @param groups The groups to compare.
+ * @return <jk>true</jk> if the two property stores are equal in the specified groups.
+ */
+ public boolean equals(PropertyStore ps, String...groups) {
+ if (this == ps)
+ return true;
+ for (String p : groups) {
+ if (p != null) {
+ PropertyGroup pg1 = this.groups.get(p), pg2 = ps.groups.get(p);
+ if (pg1 == null && pg2 == null)
+ continue;
+ if (pg1 == null || pg2 == null)
+ return false;
+ if (! pg1.equals(pg2))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Used for debugging.
+ *
+ * <p>
+ * Allows property stores to be serialized to easy-to-read JSON objects.
+ *
+ * @param beanSession The bean session.
+ * @return The property groups.
+ */
+ public Map<String,PropertyGroup> swap(BeanSession beanSession) {
+ return groups;
+ }
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // PropertyGroup
+ //-------------------------------------------------------------------------------------------------------------------
+
+ static class PropertyGroup {
+ final SortedMap<String,Property> properties;
+ private final int hashCode;
+
+ PropertyGroup(Map<String,MutableProperty> properties) {
+ TreeMap<String,Property> m = new TreeMap<>();
+ for (Map.Entry<String,MutableProperty> p : properties.entrySet())
+ m.put(p.getKey(), p.getValue().build());
+ this.properties = Collections.unmodifiableSortedMap(m);
+ this.hashCode = this.properties.hashCode();
+ }
+
+ PropertyGroupBuilder builder() {
+ return new PropertyGroupBuilder(properties);
+ }
+
+ Property get(String key) {
+ return properties.get(key);
+ }
+
+ @Override /* Object */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override /* Object */
+ public boolean equals(Object o) {
+ if (o instanceof PropertyGroup)
+ return properties.equals(((PropertyGroup)o).properties);
+ return false;
+ }
+
+ Set<String> keySet() {
+ return properties.keySet();
+ }
+
+ public Map<String,Property> swap(BeanSession beanSession) {
+ return properties;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Property
+ //-------------------------------------------------------------------------------------------------------------------
+
+ static class Property {
+ private final String name;
+ final Object value;
+ private final int hashCode;
+ private final PropertyType type;
+
+ Property(String name, Object value, PropertyType type) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+ this.hashCode = value.hashCode();
+ }
+
+ MutableProperty mutable() {
+ switch(type) {
+ case STRING:
+ case BOOLEAN:
+ case INTEGER:
+ case CLASS:
+ case OBJECT: return new MutableSimpleProperty(name, type, value);
+ case SET_STRING:
+ case SET_INTEGER:
+ case SET_CLASS: return new MutableSetProperty(name, type, value);
+ case LIST_STRING:
+ case LIST_INTEGER:
+ case LIST_CLASS:
+ case LIST_OBJECT: return new MutableListProperty(name, type, value);
+ case MAP_STRING:
+ case MAP_INTEGER:
+ case MAP_CLASS:
+ case MAP_OBJECT: return new MutableMapProperty(name, type, value);
+ }
+ throw new ConfigException("Invalid type specified: ''{0}''", type);
+ }
+
+ public <T> T as(Class<T> c) {
+ Class<?> c2 = ClassUtils.getPrimitiveWrapper(c);
+ if (c2 != null)
+ c = (Class<T>)c2;
+ if (c.isInstance(value))
+ return (T)value;
+ if (c.isArray() && value instanceof Collection)
+ return (T)asArray(c.getComponentType());
+ if (type == STRING) {
+ T t = ClassUtils.fromString(c, value.toString());
+ if (t != null)
+ return t;
+ }
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}'' on property ''{2}''", type, c, name);
+ }
+
+ public <T> T[] asArray(Class<T> eType) {
+ if (value instanceof Collection) {
+ Collection<?> l = (Collection<?>)value;
+ Object t = Array.newInstance(eType, l.size());
+ int i = 0;
+ for (Object o : l) {
+ Object o2 = null;
+ if (eType.isInstance(o))
+ o2 = o;
+ else if (type == SET_STRING || type == LIST_STRING) {
+ o2 = ClassUtils.fromString(eType, o.toString());
+ if (o2 == null)
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}[]'' on property ''{2}''", type, eType, name);
+ } else {
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}[]'' on property ''{2}''", type, eType, name);
+ }
+ Array.set(t, i++, o2);
+ }
+ return (T[])t;
+ }
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}[]'' on property ''{2}''", type, eType, name);
+ }
+
+ public <T> Set<T> asSet(Class<T> eType) {
+ if (type == SET_STRING && eType == String.class || type == SET_INTEGER && eType == Integer.class || type == SET_CLASS && eType == Class.class) {
+ return (Set<T>)value;
+ } else if (type == SET_STRING) {
+ Set<T> s = new LinkedHashSet<>();
+ for (Object o : (Set<?>)value) {
+ T t = ClassUtils.fromString(eType, o.toString());
+ if (t == null)
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''Set<{1}>'' on property ''{2}''", type, eType, name);
+ s.add(t);
+ }
+ return Collections.unmodifiableSet(s);
+ } else {
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''Set<{1}>'' on property ''{2}''", type, eType, name);
+ }
+ }
+
+ public <T> List<T> asList(Class<T> eType) {
+ if (type == LIST_STRING && eType == String.class || type == LIST_INTEGER && eType == Integer.class || type == LIST_CLASS && eType == Class.class || type == LIST_OBJECT) {
+ return (List<T>)value;
+ } else if (type == PropertyType.LIST_STRING) {
+ List<T> l = new ArrayList<>();
+ for (Object o : (List<?>)value) {
+ T t = ClassUtils.fromString(eType, o.toString());
+ if (t == null)
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''List<{1}>'' on property ''{2}''", type, eType, name);
+ l.add(t);
+ }
+ return Collections.unmodifiableList(l);
+ } else {
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''List<{1}>'' on property ''{2}''", type, eType, name);
+ }
+ }
+
+ public <T> Map<String,T> asMap(Class<T> eType) {
+ if (type == MAP_STRING && eType == String.class || type == MAP_INTEGER && eType == Integer.class || type == MAP_CLASS && eType == Class.class || type == MAP_OBJECT) {
+ return (Map<String,T>)value;
+ } else if (type == MAP_STRING) {
+ Map<String,T> m = new LinkedHashMap<>();
+ for (Map.Entry<String,String> e : ((Map<String,String>)value).entrySet()) {
+ T t = ClassUtils.fromString(eType, e.getValue());
+ if (t == null)
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''Map<String,{1}>'' on property ''{2}''", type, eType, name);
+ m.put(e.getKey(), t);
+ }
+ return Collections.unmodifiableMap(m);
+ } else {
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''Map<String,{1}>'' on property ''{2}''", type, eType, name);
+ }
+ }
+
+ public <T> T asInstance(Class<T> iType) {
+ T t = null;
+ if (type == STRING)
+ t = ClassUtils.fromString(iType, value.toString());
+ else if (type == OBJECT && iType.isInstance(value))
+ t = (T)value;
+ else if (type == CLASS)
+ t = ClassUtils.newInstance(iType, value);
+ if (t != null)
+ return t;
+ throw new ConfigException("Invalid property instantiation ''{0}'' to ''{1}'' on property ''{2}''", type, iType, name);
+ }
+
+ public <T> T[] asInstanceArray(Class<T> eType) {
+ if (value instanceof Collection) {
+ Collection<?> l = (Collection<?>)value;
+ Object t = Array.newInstance(eType, l.size());
+ int i = 0;
+ for (Object o : l) {
+ Object o2 = null;
+ if (eType.isInstance(o))
+ o2 = o;
+ else if (type == SET_STRING || type == LIST_STRING)
+ o2 = ClassUtils.fromString(eType, o.toString());
+ else if (type == SET_CLASS || type == LIST_CLASS)
+ o2 = ClassUtils.newInstance(eType, o);
+ if (o2 == null)
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}[]'' on property ''{2}''", type, eType, name);
+ Array.set(t, i++, o2);
+ }
+ return (T[])t;
+ }
+ throw new ConfigException("Invalid property conversion ''{0}'' to ''{1}[]'' on property ''{2}''", type, eType, name);
+ }
+
+ @Override /* Object */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override /* Object */
+ public boolean equals(Object o) {
+ if (o instanceof Property)
+ return ((Property)o).value.equals(value);
+ return false;
+ }
+
+ public Object swap(BeanSession beanSession) {
+ return value;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Utility methods
+ //-------------------------------------------------------------------------------------------------------------------
+
+ private static String group(String key) {
+ if (key == null || key.indexOf('.') == -1 || key.charAt(key.length()-1) == '.')
+ throw new ConfigException("Invalid property name specified: ''{0}''", key);
+ String g = key.substring(0, key.indexOf('.'));
+ if (g.isEmpty())
+ throw new ConfigException("Invalid property name specified: ''{0}''", key);
+ return g;
+ }
+
+ @Override /* Object */
+ public String toString() {
+ return JsonSerializer.DEFAULT_LAX.toString(this);
+ }
+}