This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 65731f4 PropertyStore refactoring.
65731f4 is described below
commit 65731f49524874cee0deed9686c5a6dfe25533b9
Author: JamesBognar <[email protected]>
AuthorDate: Sun Feb 7 16:39:53 2021 -0500
PropertyStore refactoring.
---
.../main/java/org/apache/juneau/config/Config.java | 2 +-
.../org/apache/juneau/BeanTraverseContext.java | 4 +--
.../main/java/org/apache/juneau/PropertyStore.java | 40 +++++-----------------
.../main/java/org/apache/juneau/parser/Parser.java | 2 +-
.../apache/juneau/serializer/WriterSerializer.java | 2 +-
.../apache/juneau/rest/RestOperationContext.java | 2 +-
.../java/org/apache/juneau/ContextCacheTest.java | 2 +-
7 files changed, 16 insertions(+), 38 deletions(-)
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
index ce7480d..52559a8 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
@@ -460,7 +460,7 @@ public final class Config extends Context implements
ConfigEventListener, Writab
.bean(Config.class, this)
.build()
.createSession();
- binaryLineLength = ps.getInteger(CONFIG_binaryLineLength);
+ binaryLineLength =
ps.getInteger(CONFIG_binaryLineLength).orElse(-1);
binaryFormat = ps.get(CONFIG_binaryFormat,
BinaryFormat.class).orElse(BinaryFormat.BASE64);
multiLineValuesOnSeparateLines =
getBoolean(CONFIG_multiLineValuesOnSeparateLines, false);
readOnly = getBoolean(CONFIG_readOnly, false);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
index f77131b..47343e8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
@@ -271,8 +271,8 @@ public abstract class BeanTraverseContext extends
BeanContext {
protected BeanTraverseContext(PropertyStore ps) {
super(ps);
- maxDepth = ps.getInteger(BEANTRAVERSE_maxDepth, 100);
- initialDepth = ps.getInteger(BEANTRAVERSE_initialDepth, 0);
+ maxDepth = ps.getInteger(BEANTRAVERSE_maxDepth).orElse(100);
+ initialDepth =
ps.getInteger(BEANTRAVERSE_initialDepth).orElse(0);
ignoreRecursions =
ps.getBoolean(BEANTRAVERSE_ignoreRecursions).orElse(false);
detectRecursions =
ps.getBoolean(BEANTRAVERSE_detectRecursions).orElse(ignoreRecursions);
}
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
index 8c55492..161be63 100644
---
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
@@ -339,7 +339,7 @@ public final class PropertyStore {
}
/**
- * Shortcut for calling <code>getProperty(key, Boolean.<jk>class</jk>,
def)</code>.
+ * Shortcut for calling <code>get(key, Boolean.<jk>class</jk>)</code>.
*
* @param key The property name.
* @return The property value, never <jk>null</jk>.
@@ -364,45 +364,23 @@ public final class PropertyStore {
}
/**
- * Shortcut for calling <code>getProperty(key, Integer.<jk>class</jk>,
def)</code>.
+ * Shortcut for calling <code>get(key, Integer.<jk>class</jk>)</code>.
*
* @param key The property name.
- * @param def The default value.
- * @return The property value, or the default value if it doesn't exist.
- */
- public final Integer getInteger(String key, Integer def) {
- return get(key, Integer.class, def);
- }
-
- /**
- * Shortcut for calling <code>getProperty(key, Integer.<jk>class</jk>,
-1)</code>.
- *
- * @param key The property name.
- * @return The property value, or <c>-1</c> if it doesn't exist.
- */
- public final int getInteger(String key) {
- return getInteger(key, -1);
- }
-
- /**
- * Shortcut for calling <code>getProperty(key, Long.<jk>class</jk>,
def)</code>.
- *
- * @param key The property name.
- * @param def The default value.
- * @return The property value, or the default value if it doesn't exist.
+ * @return The property value, never <jk>null</jk>.
*/
- public final Long getLong(String key, Long def) {
- return get(key, Long.class, def);
+ public final Optional<Integer> getInteger(String key) {
+ return Optional.ofNullable(find(key, Integer.class));
}
/**
- * Shortcut for calling <code>getProperty(key, Long.<jk>class</jk>,
-1)</code>.
+ * Shortcut for calling <code>get(key, Long.<jk>class</jk>)</code>.
*
* @param key The property name.
- * @return The property value, or <c>-1</c> if it doesn't exist.
+ * @return The property value, never <jk>null</jk>.
*/
- public final long getLong(String key) {
- return getLong(key, -1l);
+ public final Optional<Long> getLong(String key) {
+ return Optional.ofNullable(find(key, Long.class));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
index 5b29852..06addec 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
@@ -542,7 +542,7 @@ public abstract class Parser extends BeanContext {
trimStrings = ps.getBoolean(PARSER_trimStrings).orElse(false);
strict = ps.getBoolean(PARSER_strict).orElse(false);
autoCloseStreams =
ps.getBoolean(PARSER_autoCloseStreams).orElse(false);
- debugOutputLines = ps.getInteger(PARSER_debugOutputLines, 5);
+ debugOutputLines =
ps.getInteger(PARSER_debugOutputLines).orElse(5);
unbuffered = ps.getBoolean(PARSER_unbuffered).orElse(false);
listener = ps.getClass(PARSER_listener, ParserListener.class);
this.consumes = new MediaType[consumes.length];
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
index f0a785c..478c273 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
@@ -339,7 +339,7 @@ public abstract class WriterSerializer extends Serializer {
protected WriterSerializer(PropertyStore ps, String produces, String
accept) {
super(ps, produces, accept);
- maxIndent = ps.getInteger(WSERIALIZER_maxIndent, 100);
+ maxIndent = ps.getInteger(WSERIALIZER_maxIndent).orElse(100);
quoteChar = ps.getString(WSERIALIZER_quoteChar, "\"").charAt(0);
streamCharset = ps.get(WSERIALIZER_streamCharset,
Charset.class).orElse(IOUtils.UTF8);
fileCharset = ps.get(WSERIALIZER_fileCharset,
Charset.class).orElse(Charset.defaultCharset());
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
index a4630ea..135ee8f 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java
@@ -809,7 +809,7 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
opParams = context.findRestOperationParams(mi.inner(),
bf);
- this.priority = ps.getInteger(RESTOP_priority, 0);
+ this.priority =
ps.getInteger(RESTOP_priority).orElse(0);
this.callLogger = context.getCallLogger();
} catch (ServletException e) {
diff --git a/juneau-utest/src/test/java/org/apache/juneau/ContextCacheTest.java
b/juneau-utest/src/test/java/org/apache/juneau/ContextCacheTest.java
index e81e643..2a20bcf 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/ContextCacheTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/ContextCacheTest.java
@@ -157,7 +157,7 @@ public class ContextCacheTest {
public B(PropertyStore ps) {
super(ps);
- f2 = getPropertyStore().getInteger("B.f2.i");
+ f2 = getPropertyStore().getInteger("B.f2.i").orElse(-1);
}