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 9bfeda0 PropertyStore refactoring.
9bfeda0 is described below
commit 9bfeda0a4088a79c94497e3580391137652b5b9a
Author: JamesBognar <[email protected]>
AuthorDate: Sun Feb 7 18:44:37 2021 -0500
PropertyStore refactoring.
---
.../main/java/org/apache/juneau/PropertyStore.java | 94 +---------------------
.../apache/juneau/rest/RestOperationContext.java | 4 +-
2 files changed, 5 insertions(+), 93 deletions(-)
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 999da7c..5fa0d69 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
@@ -440,49 +440,11 @@ public final class PropertyStore {
*
* @param key The property name.
* @param eType The class type of the elements in the property.
- * @return The property value as an unmodifiable <c>LinkedHashSet</c>,
or an empty set if it doesn't exist.
+ * @return The property value as an unmodifiable <c>LinkedHashSet</c>,
or never <jk>null</jk>.
*/
- public <T> Set<T> getSet(String key, Class<T> eType) {
+ public <T> Optional<Set<T>> getSet(String key, Class<T> eType) {
Property p = findProperty(key);
- return p == null ? Collections.EMPTY_SET : p.asSet(eType);
- }
-
- /**
- * Returns the set property 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 if the property doesn't exist or is
empty.
- * @return The property value as an unmodifiable <c>LinkedHashSet</c>,
or the default value if it doesn't exist or is empty.
- */
- public <T> Set<T> getSet(String key, Class<T> eType, Set<T> def) {
- Set<T> l = getSet(key, eType);
- return (l.isEmpty() ? def : l);
- }
-
- /**
- * Returns the class set property with the specified name.
- *
- * @param key The property name.
- * @return The property value as an unmodifiable <c>LinkedHashSet</c>,
or an empty set if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public Set<Class<?>> getClassSet(String key) {
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_SET :
(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 <c>LinkedHashSet</c>,
or an empty set if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public <T> Set<Class<T>> getClassSet(String key, Class<T> eType) {
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_SET :
(Set)p.asSet(Class.class);
+ return Optional.ofNullable(p == null ? null : p.asSet(eType));
}
/**
@@ -511,31 +473,6 @@ public final class PropertyStore {
}
/**
- * Returns the class list property with the specified name.
- *
- * @param key The property name.
- * @return The property value as an unmodifiable <c>ArrayList</c>, or
an empty list if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public List<Class<?>> getClassList(String key) {
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_LIST :
(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 <c>ArrayList</c>, or
an empty list if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public <T> List<Class<T>> getClassList(String key, Class<T> eType) {
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_LIST :
(List)p.asList(Class.class);
- }
-
- /**
* Returns the map property with the specified name.
*
* @param key The property name.
@@ -548,31 +485,6 @@ public final class PropertyStore {
}
/**
- * Returns the class map property with the specified name.
- *
- * @param key The property name.
- * @return The property value as an unmodifiable <c>LinkedHashMap</c>,
or an empty map if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public Map<String,Class<?>> getClassMap(String key) {
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_MAP :
(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 <c>LinkedHashMap</c>,
or an empty map if it doesn't exist.
- */
- @SuppressWarnings("rawtypes")
- public <T> Map<String,Class<T>> getClassMap(String key, Class<T> eType)
{
- Property p = findProperty(key);
- return p == null ? Collections.EMPTY_MAP :
(Map)p.asMap(Class.class);
- }
-
- /**
* Returns an instance of the specified class, string, or object
property.
*
* <p>
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 0e41e05..e21e1cb 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
@@ -934,8 +934,8 @@ public class RestOperationContext extends BeanContext
implements Comparable<Rest
if (x.isEmpty())
x = beanFactory.getBean(RestGuardList.class).orElse(x);
- Set<String> rolesDeclared =
properties.getSet(REST_rolesDeclared, String.class, null);
- Set<String> roleGuard = properties.getSet(REST_roleGuard,
String.class, Collections.emptySet());
+ Set<String> rolesDeclared =
properties.getSet(REST_rolesDeclared, String.class).orElse(null);
+ Set<String> roleGuard = properties.getSet(REST_roleGuard,
String.class).orElse(Collections.emptySet());
for (String rg : roleGuard) {
try {