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 d70e408 Context API refactoring.
d70e408 is described below
commit d70e408561a67c7d89185abbb613faf682dcbb8a
Author: JamesBognar <[email protected]>
AuthorDate: Fri Sep 3 14:03:47 2021 -0400
Context API refactoring.
---
.../jena/annotation/RdfConfigAnnotation.java | 134 +++++++++++----------
.../java/org/apache/juneau/AnnotationApplier.java | 103 +++++-----------
.../juneau/annotation/BeanConfigAnnotation.java | 67 ++++-------
.../html/annotation/HtmlConfigAnnotation.java | 12 +-
.../html/annotation/HtmlDocConfigAnnotation.java | 8 +-
.../json/annotation/JsonConfigAnnotation.java | 8 +-
.../annotation/JsonSchemaConfigAnnotation.java | 23 ++--
.../annotation/MsgPackConfigAnnotation.java | 2 +-
.../oapi/annotation/OpenApiConfigAnnotation.java | 4 +-
.../parser/annotation/ParserConfigAnnotation.java | 28 ++---
.../annotation/SerializerConfigAnnotation.java | 63 ++++------
.../soap/annotation/SoapXmlConfigAnnotation.java | 2 +-
.../juneau/uon/annotation/UonConfigAnnotation.java | 10 +-
.../annotation/UrlEncodingConfigAnnotation.java | 6 +-
.../juneau/xml/annotation/XmlConfigAnnotation.java | 20 +--
.../juneau/rest/annotation/RestAnnotation.java | 82 ++++++-------
.../rest/annotation/RestDeleteAnnotation.java | 26 ++--
.../juneau/rest/annotation/RestGetAnnotation.java | 28 ++---
.../juneau/rest/annotation/RestOpAnnotation.java | 38 +++---
.../juneau/rest/annotation/RestPostAnnotation.java | 36 +++---
.../juneau/rest/annotation/RestPutAnnotation.java | 36 +++---
21 files changed, 322 insertions(+), 414 deletions(-)
diff --git
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigAnnotation.java
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigAnnotation.java
index db535d5..3b73265 100644
---
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigAnnotation.java
+++
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigAnnotation.java
@@ -45,40 +45,41 @@ public class RdfConfigAnnotation {
@Override
public void apply(AnnotationInfo<RdfConfig> ai,
RdfSerializerBuilder b) {
RdfConfig a = ai.getAnnotation();
- b.setIfNotEmpty(RDF_language, string(a.language()));
- b.setIfNotEmpty(RDF_juneauNs, string(a.juneauNs()));
- b.setIfNotEmpty(RDF_juneauBpNs, string(a.juneauBpNs()));
- b.setIfNotEmpty(RDF_disableUseXmlNamespaces,
bool(a.disableUseXmlNamespaces()));
- b.setIfNotEmpty(RDF_arp_iriRules,
string(a.arp_iriRules()));
- b.setIfNotEmpty(RDF_arp_errorMode,
string(a.arp_errorMode()));
- b.setIfNotEmpty(RDF_arp_embedding,
bool(a.arp_embedding()));
- b.setIfNotEmpty(RDF_rdfxml_xmlBase,
string(a.rdfxml_xmlBase()));
- b.setIfNotEmpty(RDF_rdfxml_longId,
bool(a.rdfxml_longId()));
- b.setIfNotEmpty(RDF_rdfxml_allowBadUris,
bool(a.rdfxml_allowBadUris()));
- b.setIfNotEmpty(RDF_rdfxml_relativeUris,
string(a.rdfxml_relativeUris()));
- b.setIfNotEmpty(RDF_rdfxml_showXmlDeclaration,
string(a.rdfxml_showXmlDeclaration()));
-
b.setIfNotEmpty(RDF_rdfxml_disableShowDoctypeDeclaration,
bool(a.rdfxml_disableShowDoctypeDeclaration()));
- b.setIfNotEmpty(RDF_rdfxml_tab, integer(a.rdfxml_tab(),
"rdfxml_tab"));
- b.setIfNotEmpty(RDF_rdfxml_attributeQuoteChar,
string(a.rdfxml_attributeQuoteChar()));
- b.setIfNotEmpty(RDF_rdfxml_blockRules,
string(a.rdfxml_blockRules()));
- b.setIfNotEmpty(RDF_n3_minGap, integer(a.n3_minGap(),
"n3_minGap"));
- b.setIfNotEmpty(RDF_n3_disableObjectLists,
bool(a.n3_disableObjectLists()));
- b.setIfNotEmpty(RDF_n3_subjectColumn,
integer(a.n3_subjectColumn(), "n3_subjectColumn"));
- b.setIfNotEmpty(RDF_n3_propertyColumn,
integer(a.n3_propertyColumn(), "n3_propertyColumn"));
- b.setIfNotEmpty(RDF_n3_indentProperty,
integer(a.n3_indentProperty(), "n3_indentProperty"));
- b.setIfNotEmpty(RDF_n3_widePropertyLen,
integer(a.n3_widePropertyLen(), "n3_widePropertyLen"));
- b.setIfNotEmpty(RDF_n3_disableAbbrevBaseUri,
bool(a.n3_disableAbbrevBaseUri()));
- b.setIfNotEmpty(RDF_n3_disableUsePropertySymbols,
bool(a.n3_disableUsePropertySymbols()));
- b.setIfNotEmpty(RDF_n3_disableUseTripleQuotedStrings,
bool(a.n3_disableUseTripleQuotedStrings()));
- b.setIfNotEmpty(RDF_n3_disableUseDoubles,
bool(a.n3_disableUseDoubles()));
- b.setIfNotEmpty(RDF_collectionFormat,
string(a.collectionFormat()));
- b.setIfNotEmpty(RDF_looseCollections,
bool(a.looseCollections()));
- b.setIfNotEmpty(RDF_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(RDF_addLiteralTypes,
bool(a.addLiteralTypes()));
- b.setIfNotEmpty(RDF_addRootProperty,
bool(a.addRootProperty()));
- b.setIfNotEmpty(RDF_disableAutoDetectNamespaces,
bool(a.disableAutoDetectNamespaces()));
+
+ string(a.language()).ifPresent(x -> b.set(RDF_language,
x));
+ string(a.juneauNs()).ifPresent(x -> b.set(RDF_juneauNs,
x));
+ string(a.juneauBpNs()).ifPresent(x ->
b.set(RDF_juneauBpNs, x));
+ bool(a.disableUseXmlNamespaces()).ifPresent(x ->
b.set(RDF_disableUseXmlNamespaces, x));
+ string(a.arp_iriRules()).ifPresent(x ->
b.set(RDF_arp_iriRules, x));
+ string(a.arp_errorMode()).ifPresent(x ->
b.set(RDF_arp_errorMode, x));
+ bool(a.arp_embedding()).ifPresent(x ->
b.set(RDF_arp_embedding, x));
+ string(a.rdfxml_xmlBase()).ifPresent(x ->
b.set(RDF_rdfxml_xmlBase, x));
+ bool(a.rdfxml_longId()).ifPresent(x ->
b.set(RDF_rdfxml_longId, x));
+ bool(a.rdfxml_allowBadUris()).ifPresent(x ->
b.set(RDF_rdfxml_allowBadUris, x));
+ string(a.rdfxml_relativeUris()).ifPresent(x ->
b.set(RDF_rdfxml_relativeUris, x));
+ string(a.rdfxml_showXmlDeclaration()).ifPresent(x ->
b.set(RDF_rdfxml_showXmlDeclaration, x));
+
bool(a.rdfxml_disableShowDoctypeDeclaration()).ifPresent(x ->
b.set(RDF_rdfxml_disableShowDoctypeDeclaration, x));
+ integer(a.rdfxml_tab(), "rdfxml_tab").ifPresent(x ->
b.set(RDF_rdfxml_tab, x));
+ string(a.rdfxml_attributeQuoteChar()).ifPresent(x ->
b.set(RDF_rdfxml_attributeQuoteChar, x));
+ string(a.rdfxml_blockRules()).ifPresent(x ->
b.set(RDF_rdfxml_blockRules, x));
+ integer(a.n3_minGap(), "n3_minGap").ifPresent(x ->
b.set(RDF_n3_minGap, x));
+ bool(a.n3_disableObjectLists()).ifPresent(x ->
b.set(RDF_n3_disableObjectLists, x));
+ integer(a.n3_subjectColumn(),
"n3_subjectColumn").ifPresent(x -> b.set(RDF_n3_subjectColumn, x));
+ integer(a.n3_propertyColumn(),
"n3_propertyColumn").ifPresent(x -> b.set(RDF_n3_propertyColumn, x));
+ integer(a.n3_indentProperty(),
"n3_indentProperty").ifPresent(x -> b.set(RDF_n3_indentProperty, x));
+ integer(a.n3_widePropertyLen(),
"n3_widePropertyLen").ifPresent(x -> b.set(RDF_n3_widePropertyLen, x));
+ bool(a.n3_disableAbbrevBaseUri()).ifPresent(x ->
b.set(RDF_n3_disableAbbrevBaseUri, x));
+ bool(a.n3_disableUsePropertySymbols()).ifPresent(x ->
b.set(RDF_n3_disableUsePropertySymbols, x));
+ bool(a.n3_disableUseTripleQuotedStrings()).ifPresent(x
-> b.set(RDF_n3_disableUseTripleQuotedStrings, x));
+ bool(a.n3_disableUseDoubles()).ifPresent(x ->
b.set(RDF_n3_disableUseDoubles, x));
+ string(a.collectionFormat()).ifPresent(x ->
b.set(RDF_collectionFormat, x));
+ bool(a.looseCollections()).ifPresent(x ->
b.set(RDF_looseCollections, x));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(RDF_addBeanTypes, x));
+ bool(a.addLiteralTypes()).ifPresent(x ->
b.set(RDF_addLiteralTypes, x));
+ bool(a.addRootProperty()).ifPresent(x ->
b.set(RDF_addRootProperty, x));
+ bool(a.disableAutoDetectNamespaces()).ifPresent(x ->
b.set(RDF_disableAutoDetectNamespaces, x));
b.setIfNotEmpty(RDF_namespaces,
stringList(a.namespaces()));
- b.setIfNotEmpty(RDF_trimWhitespace,
bool(a.trimWhitespace()));
+ bool(a.trimWhitespace()).ifPresent(x ->
b.set(RDF_trimWhitespace, x));
}
}
@@ -100,40 +101,41 @@ public class RdfConfigAnnotation {
@Override
public void apply(AnnotationInfo<RdfConfig> ai,
RdfParserBuilder b) {
RdfConfig a = ai.getAnnotation();
- b.setIfNotEmpty(RDF_language, string(a.language()));
- b.setIfNotEmpty(RDF_juneauNs, string(a.juneauNs()));
- b.setIfNotEmpty(RDF_juneauBpNs, string(a.juneauBpNs()));
- b.setIfNotEmpty(RDF_disableUseXmlNamespaces,
bool(a.disableUseXmlNamespaces()));
- b.setIfNotEmpty(RDF_arp_iriRules,
string(a.arp_iriRules()));
- b.setIfNotEmpty(RDF_arp_errorMode,
string(a.arp_errorMode()));
- b.setIfNotEmpty(RDF_arp_embedding,
bool(a.arp_embedding()));
- b.setIfNotEmpty(RDF_rdfxml_xmlBase,
string(a.rdfxml_xmlBase()));
- b.setIfNotEmpty(RDF_rdfxml_longId,
bool(a.rdfxml_longId()));
- b.setIfNotEmpty(RDF_rdfxml_allowBadUris,
bool(a.rdfxml_allowBadUris()));
- b.setIfNotEmpty(RDF_rdfxml_relativeUris,
string(a.rdfxml_relativeUris()));
- b.setIfNotEmpty(RDF_rdfxml_showXmlDeclaration,
string(a.rdfxml_showXmlDeclaration()));
-
b.setIfNotEmpty(RDF_rdfxml_disableShowDoctypeDeclaration,
bool(a.rdfxml_disableShowDoctypeDeclaration()));
- b.setIfNotEmpty(RDF_rdfxml_tab, integer(a.rdfxml_tab(),
"rdfxml_tab"));
- b.setIfNotEmpty(RDF_rdfxml_attributeQuoteChar,
string(a.rdfxml_attributeQuoteChar()));
- b.setIfNotEmpty(RDF_rdfxml_blockRules,
string(a.rdfxml_blockRules()));
- b.setIfNotEmpty(RDF_n3_minGap, integer(a.n3_minGap(),
"n3_minGap"));
- b.setIfNotEmpty(RDF_n3_disableObjectLists,
bool(a.n3_disableObjectLists()));
- b.setIfNotEmpty(RDF_n3_subjectColumn,
integer(a.n3_subjectColumn(), "n3_subjectColumn"));
- b.setIfNotEmpty(RDF_n3_propertyColumn,
integer(a.n3_propertyColumn(), "n3_propertyColumn"));
- b.setIfNotEmpty(RDF_n3_indentProperty,
integer(a.n3_indentProperty(), "n3_indentProperty"));
- b.setIfNotEmpty(RDF_n3_widePropertyLen,
integer(a.n3_widePropertyLen(), "n3_widePropertyLen"));
- b.setIfNotEmpty(RDF_n3_disableAbbrevBaseUri,
bool(a.n3_disableAbbrevBaseUri()));
- b.setIfNotEmpty(RDF_n3_disableUsePropertySymbols,
bool(a.n3_disableUsePropertySymbols()));
- b.setIfNotEmpty(RDF_n3_disableUseTripleQuotedStrings,
bool(a.n3_disableUseTripleQuotedStrings()));
- b.setIfNotEmpty(RDF_n3_disableUseDoubles,
bool(a.n3_disableUseDoubles()));
- b.setIfNotEmpty(RDF_collectionFormat,
string(a.collectionFormat()));
- b.setIfNotEmpty(RDF_looseCollections,
bool(a.looseCollections()));
- b.setIfNotEmpty(RDF_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(RDF_addLiteralTypes,
bool(a.addLiteralTypes()));
- b.setIfNotEmpty(RDF_addRootProperty,
bool(a.addRootProperty()));
- b.setIfNotEmpty(RDF_disableAutoDetectNamespaces,
bool(a.disableAutoDetectNamespaces()));
+
+ string(a.language()).ifPresent(x -> b.set(RDF_language,
x));
+ string(a.juneauNs()).ifPresent(x -> b.set(RDF_juneauNs,
x));
+ string(a.juneauBpNs()).ifPresent(x ->
b.set(RDF_juneauBpNs, x));
+ bool(a.disableUseXmlNamespaces()).ifPresent(x ->
b.set(RDF_disableUseXmlNamespaces, x));
+ string(a.arp_iriRules()).ifPresent(x ->
b.set(RDF_arp_iriRules, x));
+ string(a.arp_errorMode()).ifPresent(x ->
b.set(RDF_arp_errorMode, x));
+ bool(a.arp_embedding()).ifPresent(x ->
b.set(RDF_arp_embedding, x));
+ string(a.rdfxml_xmlBase()).ifPresent(x ->
b.set(RDF_rdfxml_xmlBase, x));
+ bool(a.rdfxml_longId()).ifPresent(x ->
b.set(RDF_rdfxml_longId, x));
+ bool(a.rdfxml_allowBadUris()).ifPresent(x ->
b.set(RDF_rdfxml_allowBadUris, x));
+ string(a.rdfxml_relativeUris()).ifPresent(x ->
b.set(RDF_rdfxml_relativeUris, x));
+ string(a.rdfxml_showXmlDeclaration()).ifPresent(x ->
b.set(RDF_rdfxml_showXmlDeclaration, x));
+
bool(a.rdfxml_disableShowDoctypeDeclaration()).ifPresent(x ->
b.set(RDF_rdfxml_disableShowDoctypeDeclaration, x));
+ integer(a.rdfxml_tab(), "rdfxml_tab").ifPresent(x ->
b.set(RDF_rdfxml_tab, x));
+ string(a.rdfxml_attributeQuoteChar()).ifPresent(x ->
b.set(RDF_rdfxml_attributeQuoteChar, x));
+ string(a.rdfxml_blockRules()).ifPresent(x ->
b.set(RDF_rdfxml_blockRules, x));
+ integer(a.n3_minGap(), "n3_minGap").ifPresent(x ->
b.set(RDF_n3_minGap, x));
+ bool(a.n3_disableObjectLists()).ifPresent(x ->
b.set(RDF_n3_disableObjectLists, x));
+ integer(a.n3_subjectColumn(),
"n3_subjectColumn").ifPresent(x -> b.set(RDF_n3_subjectColumn, x));
+ integer(a.n3_propertyColumn(),
"n3_propertyColumn").ifPresent(x -> b.set(RDF_n3_propertyColumn, x));
+ integer(a.n3_indentProperty(),
"n3_indentProperty").ifPresent(x -> b.set(RDF_n3_indentProperty, x));
+ integer(a.n3_widePropertyLen(),
"n3_widePropertyLen").ifPresent(x -> b.set(RDF_n3_widePropertyLen, x));
+ bool(a.n3_disableAbbrevBaseUri()).ifPresent(x ->
b.set(RDF_n3_disableAbbrevBaseUri, x));
+ bool(a.n3_disableUsePropertySymbols()).ifPresent(x ->
b.set(RDF_n3_disableUsePropertySymbols, x));
+ bool(a.n3_disableUseTripleQuotedStrings()).ifPresent(x
-> b.set(RDF_n3_disableUseTripleQuotedStrings, x));
+ bool(a.n3_disableUseDoubles()).ifPresent(x ->
b.set(RDF_n3_disableUseDoubles, x));
+ string(a.collectionFormat()).ifPresent(x ->
b.set(RDF_collectionFormat, x));
+ bool(a.looseCollections()).ifPresent(x ->
b.set(RDF_looseCollections, x));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(RDF_addBeanTypes, x));
+ bool(a.addLiteralTypes()).ifPresent(x ->
b.set(RDF_addLiteralTypes, x));
+ bool(a.addRootProperty()).ifPresent(x ->
b.set(RDF_addRootProperty, x));
+ bool(a.disableAutoDetectNamespaces()).ifPresent(x ->
b.set(RDF_disableAutoDetectNamespaces, x));
b.setIfNotEmpty(RDF_namespaces,
stringList(a.namespaces()));
- b.setIfNotEmpty(RDF_trimWhitespace,
bool(a.trimWhitespace()));
+ bool(a.trimWhitespace()).ifPresent(x ->
b.set(RDF_trimWhitespace, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
index b234faa..b2c0a1e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
@@ -12,14 +12,12 @@
//
***************************************************************************************************************************
package org.apache.juneau;
-import static org.apache.juneau.internal.StringUtils.*;
-
import java.lang.annotation.*;
+import java.nio.charset.*;
import java.util.*;
import java.util.stream.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.svl.*;
@@ -89,20 +87,9 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* Resolves the specified string.
*
* @param in The string containing variables to resolve.
- * @return The resolved string.
- */
- protected String string(String in) {
- in = vr.resolve(in);
- return isEmpty(in) ? null : in;
- }
-
- /**
- * Resolves the specified string.
- *
- * @param in The string containing variables to resolve.
* @return An optional containing the specified string if it exists, or
{@link Optional#empty()} if it does not.
*/
- protected Optional<String> value(String in) {
+ protected Optional<String> string(String in) {
in = vr.resolve(in);
return isEmpty(in) ? Optional.empty() : Optional.of(in);
}
@@ -113,7 +100,7 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @param in The value to return.
* @return An optional containing the specified value.
*/
- protected <T> Optional<Class<T>> value(Class<T> in) {
+ protected <T> Optional<Class<T>> type(Class<T> in) {
return in.getSimpleName().equals("Null") ? Optional.empty() :
Optional.of(in);
}
@@ -124,7 +111,7 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @return An array with resolved strings.
*/
protected List<String> stringList(String[] in) {
- return stringStream(in).collect(Collectors.toList());
+ return strings(in).collect(Collectors.toList());
}
/**
@@ -133,7 +120,7 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @param in The CDL string containing variables to resolve.
* @return An array with resolved strings.
*/
- protected Stream<String> stringStream(String[] in) {
+ protected Stream<String> strings(String[] in) {
return Arrays.asList(in).stream().map(x ->
vr.resolve(x)).filter(x -> !StringUtils.isEmpty(x));
}
@@ -143,49 +130,18 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @param in The CDL string containing variables to resolve.
* @return An array with resolved strings.
*/
- protected List<String> cdList(String in) {
- return cdStream(in).collect(Collectors.toList());
- }
-
- /**
- * Resolves the specified string as a comma-delimited list of strings.
- *
- * @param in The CDL string containing variables to resolve.
- * @return An array with resolved strings.
- */
- protected Stream<String> cdStream(String in) {
+ protected Stream<String> strings_cdl(String in) {
return
Arrays.asList(StringUtils.split(vr.resolve(in))).stream().filter(x ->
!StringUtils.isEmpty(x));
}
/**
- * Resolves the specified strings as a maps of strings-to-strings.
- *
- * @param in The string array containing variables to resolve.
- * @param loc The annotation field name.
- * @return A map of strings-to-strings.
- */
- protected Map<String,String> stringsMap(String[] in, String loc) {
- Map<String,String> m = new LinkedHashMap<>();
- for (String s : stringList(in)) {
- for (String s2 : split(s, ';')) {
- int i = s2.indexOf(':');
- if (i == -1)
- throw new ConfigException("Invalid
syntax for key/value pair on annotation @{0}({1}): {2}", ca.getSimpleName(),
loc, s2);
- m.put(s2.substring(0, i).trim(),
s2.substring(i+1).trim());
- }
- }
- return m;
- }
-
- /**
* Resolves the specified string and converts it to a boolean.
*
* @param in The string containing variables to resolve.
* @return The resolved boolean.
*/
- public Boolean bool(String in) {
- in = string(in);
- return in == null ? null : Boolean.parseBoolean(in);
+ public Optional<Boolean> bool(String in) {
+ return string(in).map(Boolean::parseBoolean);
}
/**
@@ -195,10 +151,9 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @param loc The annotation field name.
* @return The resolved int.
*/
- protected Integer integer(String in, String loc) {
+ protected Optional<Integer> integer(String in, String loc) {
try {
- in = string(in);
- return in == null ? null : Integer.parseInt(in);
+ return string(in).map(Integer::parseInt);
} catch (NumberFormatException e) {
throw new ConfigException("Invalid syntax for integer
on annotation @{0}({1}): {2}", ca.getSimpleName(), loc, in);
}
@@ -211,41 +166,39 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @param loc The annotation field name.
* @return The resolved Visibility.
*/
- protected Visibility visibility(String in, String loc) {
+ protected Optional<Visibility> visibility(String in, String loc) {
try {
- in = string(in);
- return in == null ? null : Visibility.valueOf(in);
+ return string(in).map(Visibility::valueOf);
} catch (IllegalArgumentException e) {
throw new ConfigException("Invalid syntax for
visibility on annotation @{0}({1}): {2}", ca.getSimpleName(), loc, in);
}
}
/**
- * Resolves the specified strings and converts it to an OMap.
+ * Resolves the specified string and converts it to a Charset.
*
- * @param in The strings to be concatenated and parsed into an OMap.
- * @param loc The annotation field name.
- * @return The resolved OMap.
+ * @param in The string containing variables to resolve.
+ * @return The resolved Charset.
*/
- protected OMap omap(String[] in, String loc) {
- return omap(joinnl(stringList(in)), loc);
+ protected Optional<Charset> charset(String in) {
+ return string(in).map(x -> "default".equalsIgnoreCase(x) ?
Charset.defaultCharset() : Charset.forName(x));
}
/**
- * Resolves the specified string and converts it to an OMap.
+ * Resolves the specified string and converts it to a Character.
*
- * @param in The string to be parsed into an OMap.
+ * @param in The string containing variables to resolve.
* @param loc The annotation field name.
- * @return The resolved OMap.
+ * @return The resolved Character.
*/
- protected OMap omap(String in, String loc) {
- try {
- if (! isJsonObject(in, true))
- in = "{" + in + "}";
- return OMap.ofJson(in);
- } catch (Exception e) {
- throw new ConfigException("Invalid syntax for
Simple-JSON on annotation @{0}({1}): {2}", ca.getSimpleName(), loc, in);
- }
+ protected Optional<Character> character(String in, String loc) {
+ return string(in).map(x -> toCharacter(x, loc));
+ }
+
+ private Character toCharacter(String in, String loc) {
+ if (in.length() != 1)
+ throw new ConfigException("Invalid syntax for character
on annotation @{0}({1}): {2}", ca.getSimpleName(), loc, in);
+ return in.charAt(0);
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
index fcb4847..e599d7b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
@@ -45,56 +45,41 @@ public class BeanConfigAnnotation {
public void apply(AnnotationInfo<BeanConfig> ai,
BeanContextBuilder b) {
BeanConfig a = ai.getAnnotation();
- b.setIfNotEmpty(BEAN_beanClassVisibility,
visibility(a.beanClassVisibility(), "beanClassVisibility"));
- b.setIfNotEmpty(BEAN_beanConstructorVisibility,
visibility(a.beanConstructorVisibility(), "beanConstructorVisibility"));
+ visibility(a.beanClassVisibility(),
"beanClassVisibility").ifPresent(x -> b.set(BEAN_beanClassVisibility, x));
+ visibility(a.beanConstructorVisibility(),
"beanConstructorVisibility").ifPresent(x ->
b.set(BEAN_beanConstructorVisibility, x));
b.prependTo(BEAN_beanDictionary, a.dictionary());
b.setIfNotEmpty(BEAN_beanDictionary,
a.dictionary_replace());
- b.setIfNotEmpty(BEAN_beanFieldVisibility,
visibility(a.beanFieldVisibility(), "beanFieldVisibility"));
- b.setIfNotEmpty(BEAN_beanMapPutReturnsOldValue,
bool(a.beanMapPutReturnsOldValue()));
- b.setIfNotEmpty(BEAN_beanMethodVisibility,
visibility(a.beanMethodVisibility(), "beanMethodVisibility"));
- b.setIfNotEmpty(BEAN_beansRequireDefaultConstructor,
bool(a.beansRequireDefaultConstructor()));
- b.setIfNotEmpty(BEAN_beansRequireSerializable,
bool(a.beansRequireSerializable()));
- b.setIfNotEmpty(BEAN_beansRequireSettersForGetters,
bool(a.beansRequireSettersForGetters()));
- b.setIfNotEmpty(BEAN_disableBeansRequireSomeProperties,
bool(a.disableBeansRequireSomeProperties()));
- b.setIfNotEmpty(BEAN_typePropertyName,
string(a.typePropertyName()));
- b.setIfNotEmpty(CONTEXT_debug, bool(a.debug()));
- b.setIfNotEmpty(BEAN_findFluentSetters,
bool(a.findFluentSetters()));
-
b.setIfNotEmpty(BEAN_ignoreInvocationExceptionsOnGetters,
bool(a.ignoreInvocationExceptionsOnGetters()));
-
b.setIfNotEmpty(BEAN_ignoreInvocationExceptionsOnSetters,
bool(a.ignoreInvocationExceptionsOnSetters()));
- b.setIfNotEmpty(BEAN_disableIgnoreMissingSetters,
bool(a.disableIgnoreMissingSetters()));
- b.setIfNotEmpty(BEAN_disableIgnoreTransientFields,
bool(a.disableIgnoreTransientFields()));
- b.setIfNotEmpty(BEAN_ignoreUnknownBeanProperties,
bool(a.ignoreUnknownBeanProperties()));
-
b.setIfNotEmpty(BEAN_disableIgnoreUnknownNullBeanProperties,
bool(a.disableIgnoreUnknownNullBeanProperties()));
+ visibility(a.beanFieldVisibility(),
"beanFieldVisibility").ifPresent(x -> b.set(BEAN_beanFieldVisibility, x));
+ bool(a.beanMapPutReturnsOldValue()).ifPresent(x ->
b.set(BEAN_beanMapPutReturnsOldValue, x));
+ visibility(a.beanMethodVisibility(),
"beanMethodVisibility").ifPresent(x -> b.set(BEAN_beanMethodVisibility, x));
+ bool(a.beansRequireDefaultConstructor()).ifPresent(x ->
b.set(BEAN_beansRequireDefaultConstructor, x));
+ bool(a.beansRequireSerializable()).ifPresent(x ->
b.set(BEAN_beansRequireSerializable, x));
+ bool(a.beansRequireSettersForGetters()).ifPresent(x ->
b.set(BEAN_beansRequireSettersForGetters, x));
+ bool(a.disableBeansRequireSomeProperties()).ifPresent(x
-> b.set(BEAN_disableBeansRequireSomeProperties, x));
+ string(a.typePropertyName()).ifPresent(x ->
b.set(BEAN_typePropertyName, x));
+ bool(a.debug()).ifPresent(x -> b.set(CONTEXT_debug, x));
+ bool(a.findFluentSetters()).ifPresent(x ->
b.set(BEAN_findFluentSetters, x));
+
bool(a.ignoreInvocationExceptionsOnGetters()).ifPresent(x ->
b.set(BEAN_ignoreInvocationExceptionsOnGetters, x));
+
bool(a.ignoreInvocationExceptionsOnSetters()).ifPresent(x ->
b.set(BEAN_ignoreInvocationExceptionsOnSetters, x));
+ bool(a.disableIgnoreMissingSetters()).ifPresent(x ->
b.set(BEAN_disableIgnoreMissingSetters, x));
+ bool(a.disableIgnoreTransientFields()).ifPresent(x ->
b.set(BEAN_disableIgnoreTransientFields, x));
+ bool(a.ignoreUnknownBeanProperties()).ifPresent(x ->
b.set(BEAN_ignoreUnknownBeanProperties, x));
+
bool(a.disableIgnoreUnknownNullBeanProperties()).ifPresent(x ->
b.set(BEAN_disableIgnoreUnknownNullBeanProperties, x));
asList(a.interfaces()).stream().map(x ->
BeanAnnotation.create(x).interfaceClass(x).build()).forEach(x ->
b.annotations(x));
- b.setIfNotEmpty(BEAN_locale, locale(a.locale()));
- b.setIfNotEmpty(BEAN_mediaType,
mediaType(a.mediaType()));
+
string(a.locale()).map(Locale::forLanguageTag).ifPresent(x ->
b.set(BEAN_locale, x));
+ string(a.mediaType()).map(MediaType::of).ifPresent(x ->
b.set(BEAN_mediaType, x));
b.setIfNotEmpty(BEAN_notBeanClasses,
a.notBeanClasses());
b.setIfNotEmpty(BEAN_notBeanClasses,
a.notBeanClasses_replace());
b.addTo(BEAN_notBeanPackages,
stringList(a.notBeanPackages()));
b.setIfNotEmpty(BEAN_notBeanPackages,
stringList(a.notBeanPackages_replace()));
- b.setIf(a.propertyNamer() != PropertyNamer.Null.class,
BEAN_propertyNamer, a.propertyNamer());
- b.setIfNotEmpty(BEAN_sortProperties,
bool(a.sortProperties()));
+ type(a.propertyNamer()).ifPresent(x ->
b.set(BEAN_propertyNamer, x));
+ bool(a.sortProperties()).ifPresent(x ->
b.set(BEAN_sortProperties, x));
b.prependTo(BEAN_swaps, a.swaps());
b.setIfNotEmpty(BEAN_swaps, a.swaps_replace());
- b.setIfNotEmpty(BEAN_timeZone, timeZone(a.timeZone()));
- b.setIfNotEmpty(BEAN_useEnumNames,
bool(a.useEnumNames()));
- b.setIfNotEmpty(BEAN_disableInterfaceProxies,
bool(a.disableInterfaceProxies()));
- b.setIfNotEmpty(BEAN_useJavaBeanIntrospector,
bool(a.useJavaBeanIntrospector()));
- }
-
- private Locale locale(String in) {
- in = string(in);
- return in == null ? null : Locale.forLanguageTag(in);
- }
-
- private MediaType mediaType(String in) {
- in = string(in);
- return in == null ? null : MediaType.of(in);
- }
-
- private TimeZone timeZone(String in) {
- in = string(in);
- return in == null ? null : TimeZone.getTimeZone(in);
+
string(a.timeZone()).map(TimeZone::getTimeZone).ifPresent(x ->
b.set(BEAN_timeZone, x));
+ bool(a.useEnumNames()).ifPresent(x ->
b.set(BEAN_useEnumNames, x));
+ bool(a.disableInterfaceProxies()).ifPresent(x ->
b.set(BEAN_disableInterfaceProxies, x));
+ bool(a.useJavaBeanIntrospector()).ifPresent(x ->
b.set(BEAN_useJavaBeanIntrospector, x));
}
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigAnnotation.java
index 24136b5..6e9c48e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigAnnotation.java
@@ -41,12 +41,12 @@ public class HtmlConfigAnnotation {
public void apply(AnnotationInfo<HtmlConfig> ai,
ContextPropertiesBuilder b) {
HtmlConfig a = ai.getAnnotation();
- b.setIfNotEmpty(HTML_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(HTML_addKeyValueTableHeaders,
bool(a.addKeyValueTableHeaders()));
- b.setIfNotEmpty(HTML_disableDetectLabelParameters,
bool(a.disableDetectLabelParameters()));
- b.setIfNotEmpty(HTML_disableDetectLinksInStrings,
bool(a.disableDetectLinksInStrings()));
- b.setIfNotEmpty(HTML_labelParameter,
string(a.labelParameter()));
- b.setIfNotEmpty(HTML_uriAnchorText,
string(a.uriAnchorText()));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(HTML_addBeanTypes, x));
+ bool(a.addKeyValueTableHeaders()).ifPresent(x ->
b.set(HTML_addKeyValueTableHeaders, x));
+ bool(a.disableDetectLabelParameters()).ifPresent(x ->
b.set(HTML_disableDetectLabelParameters, x));
+ bool(a.disableDetectLinksInStrings()).ifPresent(x ->
b.set(HTML_disableDetectLinksInStrings, x));
+ string(a.labelParameter()).ifPresent(x ->
b.set(HTML_labelParameter, x));
+ string(a.uriAnchorText()).ifPresent(x ->
b.set(HTML_uriAnchorText, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigAnnotation.java
index 98c5b3e..9a31360 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigAnnotation.java
@@ -54,8 +54,8 @@ public class HtmlDocConfigAnnotation {
b.setIf(a.header().length > 0, HTMLDOC_header,
resolveList(a.header(), b.peek(String[].class, HTMLDOC_header)));
b.setIf(a.nav().length > 0, HTMLDOC_nav,
resolveList(a.nav(), b.peek(String[].class, HTMLDOC_nav)));
b.setIf(a.navlinks().length > 0, HTMLDOC_navlinks,
resolveLinks(a.navlinks(), b.peek(String[].class, HTMLDOC_navlinks)));
- b.setIfNotEmpty(HTMLDOC_noResultsMessage,
string(a.noResultsMessage()));
- b.setIfNotEmpty(HTMLDOC_nowrap, bool(a.nowrap()));
+ string(a.noResultsMessage()).ifPresent(x ->
b.set(HTMLDOC_noResultsMessage, x));
+ bool(a.nowrap()).ifPresent(x -> b.set(HTMLDOC_nowrap,
x));
b.setIf(a.script().length > 0, HTMLDOC_script,
resolveList(a.script(), b.peek(String[].class, HTMLDOC_script)));
b.setIf(a.style().length > 0, HTMLDOC_style,
resolveList(a.style(), b.peek(String[].class, HTMLDOC_style)));
b.setIf(a.stylesheet().length > 0, HTMLDOC_stylesheet,
resolveList(a.stylesheet(), b.peek(String[].class, HTMLDOC_stylesheet)));
@@ -68,7 +68,7 @@ public class HtmlDocConfigAnnotation {
private String[] resolveLinks(Object[] value, String[] prev) {
AList<String> list = AList.create();
for (Object v : value) {
- String s = string(stringify(v));
+ String s = string(stringify(v)).orElse(null);
if (s == null)
return new String[0];
if ("INHERIT".equals(s)) {
@@ -91,7 +91,7 @@ public class HtmlDocConfigAnnotation {
private String[] resolveList(Object[] value, String[] prev) {
ASet<String> set = ASet.of();
for (Object v : value) {
- String s = string(stringify(v));
+ String s = string(stringify(v)).orElse(null);
if ("INHERIT".equals(s)) {
if (prev != null)
set.a(prev);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigAnnotation.java
index 6d234e9..847b5c6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigAnnotation.java
@@ -42,10 +42,10 @@ public class JsonConfigAnnotation {
public void apply(AnnotationInfo<JsonConfig> ai,
ContextPropertiesBuilder b) {
JsonConfig a = ai.getAnnotation();
- b.setIfNotEmpty(JSON_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(JSON_escapeSolidus,
bool(a.escapeSolidus()));
- b.setIfNotEmpty(JSON_simpleMode, bool(a.simpleMode()));
- b.setIfNotEmpty(JSON_validateEnd,
bool(a.validateEnd()));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(JSON_addBeanTypes, x));
+ bool(a.escapeSolidus()).ifPresent(x ->
b.set(JSON_escapeSolidus, x));
+ bool(a.simpleMode()).ifPresent(x ->
b.set(JSON_simpleMode, x));
+ bool(a.validateEnd()).ifPresent(x ->
b.set(JSON_validateEnd, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
index fe500ea..5abf50b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.BeanTraverseContext.*;
import static org.apache.juneau.jsonschema.JsonSchemaGenerator.*;
import org.apache.juneau.*;
-import org.apache.juneau.jsonschema.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.svl.*;
@@ -43,17 +42,17 @@ public class JsonSchemaConfigAnnotation {
public void apply(AnnotationInfo<JsonSchemaConfig> ai,
ContextPropertiesBuilder b) {
JsonSchemaConfig a = ai.getAnnotation();
- b.setIfNotEmpty(JSONSCHEMA_addDescriptionsTo,
string(a.addDescriptionsTo()));
- b.setIfNotEmpty(JSONSCHEMA_addExamplesTo,
string(a.addExamplesTo()));
- b.setIfNotEmpty(JSONSCHEMA_allowNestedDescriptions,
bool(a.allowNestedDescriptions()));
- b.setIfNotEmpty(JSONSCHEMA_allowNestedExamples,
bool(a.allowNestedExamples()));
- b.setIf(a.beanDefMapper() != BeanDefMapper.Null.class,
JSONSCHEMA_beanDefMapper, a.beanDefMapper());
- b.setIfNotEmpty(JSONSCHEMA_ignoreTypes,
string(a.ignoreTypes()));
- b.setIfNotEmpty(JSONSCHEMA_useBeanDefs,
bool(a.useBeanDefs()));
- b.setIfNotEmpty(BEANTRAVERSE_detectRecursions,
bool(a.detectRecursions()));
- b.setIfNotEmpty(BEANTRAVERSE_ignoreRecursions,
bool(a.ignoreRecursions()));
- b.setIfNotEmpty(BEANTRAVERSE_initialDepth,
integer(a.initialDepth(), "initialDepth"));
- b.setIfNotEmpty(BEANTRAVERSE_maxDepth,
integer(a.maxDepth(), "maxDepth"));
+ string(a.addDescriptionsTo()).ifPresent(x ->
b.set(JSONSCHEMA_addDescriptionsTo, x));
+ string(a.addExamplesTo()).ifPresent(x ->
b.set(JSONSCHEMA_addExamplesTo, x));
+ bool(a.allowNestedDescriptions()).ifPresent(x ->
b.set(JSONSCHEMA_allowNestedDescriptions, x));
+ bool(a.allowNestedExamples()).ifPresent(x ->
b.set(JSONSCHEMA_allowNestedExamples, x));
+ type(a.beanDefMapper()).ifPresent(x ->
b.set(JSONSCHEMA_beanDefMapper, x));
+ string(a.ignoreTypes()).ifPresent(x ->
b.set(JSONSCHEMA_ignoreTypes, x));
+ bool(a.useBeanDefs()).ifPresent(x ->
b.set(JSONSCHEMA_useBeanDefs, x));
+ bool(a.detectRecursions()).ifPresent(x ->
b.set(BEANTRAVERSE_detectRecursions, x));
+ bool(a.ignoreRecursions()).ifPresent(x ->
b.set(BEANTRAVERSE_ignoreRecursions, x));
+ integer(a.initialDepth(), "initialDepth").ifPresent(x
-> b.set(BEANTRAVERSE_initialDepth, x));
+ integer(a.maxDepth(), "maxDepth").ifPresent(x ->
b.set(BEANTRAVERSE_maxDepth, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackConfigAnnotation.java
index 9dcdc96..db1de73 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackConfigAnnotation.java
@@ -41,7 +41,7 @@ public class MsgPackConfigAnnotation {
public void apply(AnnotationInfo<MsgPackConfig> ai,
ContextPropertiesBuilder b) {
MsgPackConfig a = ai.getAnnotation();
- b.setIfNotEmpty(MSGPACK_addBeanTypes,
bool(a.addBeanTypes()));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(MSGPACK_addBeanTypes, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiConfigAnnotation.java
index 6fbd05f..25daa0d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiConfigAnnotation.java
@@ -41,8 +41,8 @@ public class OpenApiConfigAnnotation {
public void apply(AnnotationInfo<OpenApiConfig> ai,
ContextPropertiesBuilder b) {
OpenApiConfig a = ai.getAnnotation();
- b.setIfNotEmpty(OAPI_format, string(a.format()));
- b.setIfNotEmpty(OAPI_collectionFormat,
string(a.collectionFormat()));
+ string(a.format()).ifPresent(x -> b.set(OAPI_format,
x));
+ string(a.collectionFormat()).ifPresent(x ->
b.set(OAPI_collectionFormat, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/annotation/ParserConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/annotation/ParserConfigAnnotation.java
index 180f3fc..77a7d6d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/annotation/ParserConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/annotation/ParserConfigAnnotation.java
@@ -15,10 +15,7 @@ package org.apache.juneau.parser.annotation;
import static org.apache.juneau.parser.InputStreamParser.*;
import static org.apache.juneau.parser.ReaderParser.*;
-import java.nio.charset.*;
-
import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.svl.*;
@@ -45,22 +42,15 @@ public class ParserConfigAnnotation {
public void apply(AnnotationInfo<ParserConfig> ai,
ContextPropertiesBuilder b) {
ParserConfig a = ai.getAnnotation();
- b.setIfNotEmpty(PARSER_autoCloseStreams,
bool(a.autoCloseStreams()));
- b.setIfNotEmpty(PARSER_debugOutputLines,
integer(a.debugOutputLines(), "debugOutputLines"));
- b.setIf(a.listener() != ParserListener.Null.class,
PARSER_listener, a.listener());
- b.setIfNotEmpty(PARSER_strict, bool(a.strict()));
- b.setIfNotEmpty(PARSER_trimStrings,
bool(a.trimStrings()));
- b.setIfNotEmpty(PARSER_unbuffered,
bool(a.unbuffered()));
- b.setIfNotEmpty(ISPARSER_binaryFormat,
string(a.binaryFormat()));
- b.setIfNotEmpty(RPARSER_fileCharset,
charset(a.fileCharset()));
- b.setIfNotEmpty(RPARSER_streamCharset,
charset(a.streamCharset()));
- }
-
- private Object charset(String in) {
- String s = string(in);
- if ("default".equalsIgnoreCase(s))
- return Charset.defaultCharset();
- return s;
+ bool(a.autoCloseStreams()).ifPresent(x ->
b.set(PARSER_autoCloseStreams, x));
+ integer(a.debugOutputLines(),
"debugOutputLines").ifPresent(x -> b.set(PARSER_debugOutputLines, x));
+ type(a.listener()).ifPresent(x ->
b.set(PARSER_listener, x));
+ bool(a.strict()).ifPresent(x -> b.set(PARSER_strict,
x));
+ bool(a.trimStrings()).ifPresent(x ->
b.set(PARSER_trimStrings, x));
+ bool(a.unbuffered()).ifPresent(x ->
b.set(PARSER_unbuffered, x));
+ string(a.binaryFormat()).ifPresent(x ->
b.set(ISPARSER_binaryFormat, x));
+ charset(a.fileCharset()).ifPresent(x ->
b.set(RPARSER_fileCharset, x));
+ charset(a.streamCharset()).ifPresent(x ->
b.set(RPARSER_streamCharset, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
index 0ac317e..2ff27a4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
@@ -16,11 +16,8 @@ import static org.apache.juneau.BeanTraverseContext.*;
import static org.apache.juneau.serializer.OutputStreamSerializer.*;
import static org.apache.juneau.serializer.WriterSerializer.*;
-import java.nio.charset.*;
-
import org.apache.juneau.*;
import org.apache.juneau.reflect.*;
-import org.apache.juneau.serializer.*;
import org.apache.juneau.svl.*;
/**
@@ -46,44 +43,28 @@ public class SerializerConfigAnnotation {
public void apply(AnnotationInfo<SerializerConfig> ai,
ContextPropertiesBuilder b) {
SerializerConfig a = ai.getAnnotation();
- b.setIfNotEmpty(SERIALIZER_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(SERIALIZER_addRootType,
bool(a.addRootType()));
- b.setIfNotEmpty(SERIALIZER_keepNullProperties,
bool(a.keepNullProperties()));
- b.setIf(a.listener() != SerializerListener.Null.class,
SERIALIZER_listener, a.listener());
- b.setIfNotEmpty(SERIALIZER_sortCollections,
bool(a.sortCollections()));
- b.setIfNotEmpty(SERIALIZER_sortMaps,
bool(a.sortMaps()));
- b.setIfNotEmpty(SERIALIZER_trimEmptyCollections,
bool(a.trimEmptyCollections()));
- b.setIfNotEmpty(SERIALIZER_trimEmptyMaps,
bool(a.trimEmptyMaps()));
- b.setIfNotEmpty(SERIALIZER_trimStrings,
bool(a.trimStrings()));
- b.setIfNotEmpty(SERIALIZER_uriContext,
string(a.uriContext()));
- b.setIfNotEmpty(SERIALIZER_uriRelativity,
string(a.uriRelativity()));
- b.setIfNotEmpty(SERIALIZER_uriResolution,
string(a.uriResolution()));
- b.setIfNotEmpty(OSSERIALIZER_binaryFormat,
string(a.binaryFormat()));
- b.setIfNotEmpty(WSERIALIZER_fileCharset,
charset(a.fileCharset()));
- b.setIfNotEmpty(WSERIALIZER_maxIndent,
integer(a.maxIndent(), "maxIndent"));
- b.setIfNotEmpty(WSERIALIZER_quoteChar,
character(a.quoteChar(), "quoteChar"));
- b.setIfNotEmpty(WSERIALIZER_streamCharset,
charset(a.streamCharset()));
- b.setIfNotEmpty(WSERIALIZER_useWhitespace,
bool(a.useWhitespace()));
- b.setIfNotEmpty(BEANTRAVERSE_detectRecursions,
bool(a.detectRecursions()));
- b.setIfNotEmpty(BEANTRAVERSE_ignoreRecursions,
bool(a.ignoreRecursions()));
- b.setIfNotEmpty(BEANTRAVERSE_initialDepth,
integer(a.initialDepth(), "initialDepth"));
- b.setIfNotEmpty(BEANTRAVERSE_maxDepth,
integer(a.maxDepth(), "maxDepth"));
- }
-
- private Object charset(String in) {
- String s = string(in);
- if ("default".equalsIgnoreCase(s))
- return Charset.defaultCharset();
- return s;
- }
-
- private Character character(String in, String loc) {
- String s = string(in);
- if (s == null)
- return null;
- if (s.length() != 1)
- throw new ConfigException("Invalid syntax for
character on annotation @{0}({1}): {2}", "SerializerConfig", loc, in);
- return s.charAt(0);
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(SERIALIZER_addBeanTypes, x));
+ bool(a.addRootType()).ifPresent(x ->
b.set(SERIALIZER_addRootType, x));
+ bool(a.keepNullProperties()).ifPresent(x ->
b.set(SERIALIZER_keepNullProperties, x));
+ type(a.listener()).ifPresent(x ->
b.set(SERIALIZER_listener, x));
+ bool(a.sortCollections()).ifPresent(x ->
b.set(SERIALIZER_sortCollections, x));
+ bool(a.sortMaps()).ifPresent(x ->
b.set(SERIALIZER_sortMaps, x));
+ bool(a.trimEmptyCollections()).ifPresent(x ->
b.set(SERIALIZER_trimEmptyCollections, x));
+ bool(a.trimEmptyMaps()).ifPresent(x ->
b.set(SERIALIZER_trimEmptyMaps, x));
+ bool(a.trimStrings()).ifPresent(x ->
b.set(SERIALIZER_trimStrings, x));
+ string(a.uriContext()).ifPresent(x ->
b.set(SERIALIZER_uriContext, x));
+ string(a.uriRelativity()).ifPresent(x ->
b.set(SERIALIZER_uriRelativity, x));
+ string(a.uriResolution()).ifPresent(x ->
b.set(SERIALIZER_uriResolution, x));
+ string(a.binaryFormat()).ifPresent(x ->
b.set(OSSERIALIZER_binaryFormat, x));
+ charset(a.fileCharset()).ifPresent(x ->
b.set(WSERIALIZER_fileCharset, x));
+ integer(a.maxIndent(), "maxIndent").ifPresent(x ->
b.set(WSERIALIZER_maxIndent, x));
+ character(a.quoteChar(), "quoteChar").ifPresent(x ->
b.set(WSERIALIZER_quoteChar, x));
+ charset(a.streamCharset()).ifPresent(x ->
b.set(WSERIALIZER_streamCharset, x));
+ bool(a.useWhitespace()).ifPresent(x ->
b.set(WSERIALIZER_useWhitespace, x));
+ bool(a.detectRecursions()).ifPresent(x ->
b.set(BEANTRAVERSE_detectRecursions, x));
+ bool(a.ignoreRecursions()).ifPresent(x ->
b.set(BEANTRAVERSE_ignoreRecursions, x));
+ integer(a.initialDepth(), "initialDepth").ifPresent(x
-> b.set(BEANTRAVERSE_initialDepth, x));
+ integer(a.maxDepth(), "maxDepth").ifPresent(x ->
b.set(BEANTRAVERSE_maxDepth, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlConfigAnnotation.java
index f2ff30c..2dc4e2f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlConfigAnnotation.java
@@ -41,7 +41,7 @@ public class SoapXmlConfigAnnotation {
public void apply(AnnotationInfo<SoapXmlConfig> ai,
ContextPropertiesBuilder b) {
SoapXmlConfig a = ai.getAnnotation();
- b.setIfNotEmpty(SOAPXML_SOAPAction,
string(a.soapAction()));
+ string(a.soapAction()).ifPresent(x ->
b.set(SOAPXML_SOAPAction, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonConfigAnnotation.java
index 45cbfb7..e937f04 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonConfigAnnotation.java
@@ -42,11 +42,11 @@ public class UonConfigAnnotation {
public void apply(AnnotationInfo<UonConfig> ai,
ContextPropertiesBuilder b) {
UonConfig a = ai.getAnnotation();
- b.setIfNotEmpty(UON_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(UON_encoding, bool(a.encoding()));
- b.setIfNotEmpty(UON_paramFormat,
string(a.paramFormat()));
- b.setIfNotEmpty(UON_decoding, bool(a.decoding()));
- b.setIfNotEmpty(UON_validateEnd, bool(a.validateEnd()));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(UON_addBeanTypes, x));
+ bool(a.encoding()).ifPresent(x -> b.set(UON_encoding,
x));
+ string(a.paramFormat()).ifPresent(x ->
b.set(UON_paramFormat, x));
+ bool(a.decoding()).ifPresent(x -> b.set(UON_decoding,
x));
+ bool(a.validateEnd()).ifPresent(x ->
b.set(UON_validateEnd, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigAnnotation.java
index a7b4295..cbcaa84 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigAnnotation.java
@@ -40,10 +40,8 @@ public class UrlEncodingConfigAnnotation {
public void apply(AnnotationInfo<UrlEncodingConfig> ai,
ContextPropertiesBuilder b) {
UrlEncodingConfig a = ai.getAnnotation();
- if (! a.expandedParams().isEmpty()) {
-
b.set(UrlEncodingSerializer.URLENC_expandedParams, bool(a.expandedParams()));
- b.set(UrlEncodingParser.URLENC_expandedParams,
bool(a.expandedParams()));
- }
+ bool(a.expandedParams()).ifPresent(x ->
b.set(UrlEncodingSerializer.URLENC_expandedParams, x));
+ bool(a.expandedParams()).ifPresent(x ->
b.set(UrlEncodingParser.URLENC_expandedParams, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
index 543dbee..fea6334 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
@@ -43,17 +43,17 @@ public class XmlConfigAnnotation {
public void apply(AnnotationInfo<XmlConfig> ai,
ContextPropertiesBuilder b) {
XmlConfig a = ai.getAnnotation();
- b.setIfNotEmpty(XML_addBeanTypes,
bool(a.addBeanTypes()));
- b.setIfNotEmpty(XML_addNamespaceUrisToRoot,
bool(a.addNamespaceUrisToRoot()));
- b.setIfNotEmpty(XML_disableAutoDetectNamespaces,
bool(a.disableAutoDetectNamespaces()));
- b.setIfNotEmpty(XML_defaultNamespace,
string(a.defaultNamespace()));
- b.setIfNotEmpty(XML_enableNamespaces,
bool(a.enableNamespaces()));
+ bool(a.addBeanTypes()).ifPresent(x ->
b.set(XML_addBeanTypes, x));
+ bool(a.addNamespaceUrisToRoot()).ifPresent(x ->
b.set(XML_addNamespaceUrisToRoot, x));
+ bool(a.disableAutoDetectNamespaces()).ifPresent(x ->
b.set(XML_disableAutoDetectNamespaces, x));
+ string(a.defaultNamespace()).ifPresent(x ->
b.set(XML_defaultNamespace, x));
+ bool(a.enableNamespaces()).ifPresent(x ->
b.set(XML_enableNamespaces, x));
b.setIf(a.namespaces().length > 0, XML_namespaces,
Namespace.createArray(stringList(a.namespaces())));
- b.setIf(a.eventAllocator() !=
XmlEventAllocator.Null.class, XML_eventAllocator, a.eventAllocator());
- b.setIfNotEmpty(XML_preserveRootElement,
bool(a.preserveRootElement()));
- b.setIf(a.reporter() != XmlReporter.Null.class,
XML_reporter, a.reporter());
- b.setIf(a.resolver() != XmlResolver.Null.class,
XML_resolver, a.resolver());
- b.setIfNotEmpty(XML_validating, bool(a.validating()));
+ type(a.eventAllocator()).ifPresent(x ->
b.set(XML_eventAllocator, x));
+ bool(a.preserveRootElement()).ifPresent(x ->
b.set(XML_preserveRootElement, x));
+ type(a.reporter()).ifPresent(x -> b.set(XML_reporter,
x));
+ type(a.resolver()).ifPresent(x -> b.set(XML_resolver,
x));
+ bool(a.validating()).ifPresent(x ->
b.set(XML_validating, x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
index b7b98ac..69e3313 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
@@ -1041,42 +1041,42 @@ public class RestAnnotation {
Rest a = ai.getAnnotation();
ClassInfo c = ai.getClassOn();
- b.setIf(a.partSerializer() !=
HttpPartSerializer.Null.class, REST_partSerializer, a.partSerializer());
- b.setIf(a.partParser() != HttpPartParser.Null.class,
REST_partParser, a.partParser());
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.consumes()).map(MediaType::of).forEach(x
-> b.consumes(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
- value(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.partSerializer()).ifPresent(x ->
b.set(REST_partSerializer, x));
+ type(a.partParser()).ifPresent(x ->
b.set(REST_partParser, x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.consumes()).map(MediaType::of).forEach(x ->
b.consumes(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ string(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.responseProcessors(a.responseProcessors());
b.children((Object[])a.children());
b.restOpArgs(a.restOpArgs());
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- value(a.uriContext()).ifPresent(x -> b.uriContext(x));
- value(a.uriAuthority()).ifPresent(x ->
b.uriAuthority(x));
-
value(a.uriRelativity()).map(UriRelativity::valueOf).ifPresent(x ->
b.uriRelativity(x));
-
value(a.uriResolution()).map(UriResolution::valueOf).ifPresent(x ->
b.uriResolution(x));
- b.prependTo(REST_messages, Tuple2.of(c.inner(),
string(a.messages())));
- b.setIf(a.fileFinder() != FileFinder.Null.class,
REST_fileFinder, a.fileFinder());
- b.setIf(a.staticFiles() != StaticFiles.Null.class,
REST_staticFiles, a.staticFiles());
- value(a.path()).ifPresent(x -> b.path(x));
- value(a.clientVersionHeader()).ifPresent(x ->
b.clientVersionHeader(x));
- b.setIf(a.beanStore() != BeanStore.Null.class,
REST_beanStore, a.beanStore());
- value(a.callLogger()).ifPresent(x -> b.callLogger(x));
- value(a.swaggerProvider()).ifPresent(x ->
b.swaggerProvider(x));
- value(a.restOpContextClass()).ifPresent(x ->
b.restOpContextClass(x));
- value(a.restChildrenClass()).ifPresent(x ->
b.restChildrenClass(x));
- value(a.restOperationsClass()).ifPresent(x ->
b.restOperationsClass(x));
- value(a.debugEnablement()).ifPresent(x ->
b.debugEnablement(x));
-
value(a.disableBodyParam()).map(Boolean::parseBoolean).ifPresent(x ->
b.disableBodyParam(x));
- value(a.allowedHeaderParams()).ifPresent(x ->
b.allowedHeaderParams(x));
- value(a.allowedMethodHeaders()).ifPresent(x ->
b.allowedMethodHeaders(x));
- value(a.allowedMethodParams()).ifPresent(x ->
b.allowedMethodParams(x));
- b.setIfNotEmpty(REST_renderResponseStackTraces,
bool(a.renderResponseStackTraces()));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
- value(a.debugOn()).ifPresent(x -> b.debugOn(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ string(a.uriContext()).ifPresent(x -> b.uriContext(x));
+ string(a.uriAuthority()).ifPresent(x ->
b.uriAuthority(x));
+
string(a.uriRelativity()).map(UriRelativity::valueOf).ifPresent(x ->
b.uriRelativity(x));
+
string(a.uriResolution()).map(UriResolution::valueOf).ifPresent(x ->
b.uriResolution(x));
+ b.prependTo(REST_messages, Tuple2.of(c.inner(),
string(a.messages()).orElse(null)));
+ type(a.fileFinder()).ifPresent(x ->
b.set(REST_fileFinder, x));
+ type(a.staticFiles()).ifPresent(x ->
b.set(REST_staticFiles, x));
+ string(a.path()).ifPresent(x -> b.path(x));
+ string(a.clientVersionHeader()).ifPresent(x ->
b.clientVersionHeader(x));
+ type(a.beanStore()).ifPresent(x ->
b.set(REST_beanStore, x));
+ type(a.callLogger()).ifPresent(x -> b.callLogger(x));
+ type(a.swaggerProvider()).ifPresent(x ->
b.swaggerProvider(x));
+ type(a.restOpContextClass()).ifPresent(x ->
b.restOpContextClass(x));
+ type(a.restChildrenClass()).ifPresent(x ->
b.restChildrenClass(x));
+ type(a.restOperationsClass()).ifPresent(x ->
b.restOperationsClass(x));
+ type(a.debugEnablement()).ifPresent(x ->
b.debugEnablement(x));
+
string(a.disableBodyParam()).map(Boolean::parseBoolean).ifPresent(x ->
b.disableBodyParam(x));
+ string(a.allowedHeaderParams()).ifPresent(x ->
b.allowedHeaderParams(x));
+ string(a.allowedMethodHeaders()).ifPresent(x ->
b.allowedMethodHeaders(x));
+ string(a.allowedMethodParams()).ifPresent(x ->
b.allowedMethodParams(x));
+ bool(a.renderResponseStackTraces()).ifPresent(x ->
b.set(REST_renderResponseStackTraces, x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.debugOn()).ifPresent(x -> b.debugOn(x));
}
}
@@ -1100,17 +1100,17 @@ public class RestAnnotation {
b.set(REST_serializers,
merge(ConverterUtils.toType(b.peek(REST_serializers), Object[].class),
a.serializers()));
b.set(REST_parsers,
merge(ConverterUtils.toType(b.peek(REST_parsers), Object[].class),
a.parsers()));
- b.setIf(a.partSerializer() !=
HttpPartSerializer.Null.class, REST_partSerializer, a.partSerializer());
- b.setIf(a.partParser() != HttpPartParser.Null.class,
REST_partParser, a.partParser());
+ type(a.partSerializer()).ifPresent(x ->
b.set(REST_partSerializer, x));
+ type(a.partParser()).ifPresent(x ->
b.set(REST_partParser, x));
b.prependTo(REST_encoders, a.encoders());
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.consumes()).map(MediaType::of).forEach(x
-> b.consumes(x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.consumes()).map(MediaType::of).forEach(x ->
b.consumes(x));
b.converters(a.converters());
b.guards(a.guards());
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- value(a.maxInput()).ifPresent(x -> b.maxInput(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ string(a.maxInput()).ifPresent(x -> b.maxInput(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
index fc815fd..b250b8a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDeleteAnnotation.java
@@ -457,21 +457,21 @@ public class RestDeleteAnnotation {
b.httpMethod("delete");
b.set(REST_encoders,
merge(ConverterUtils.toType(b.peek(REST_encoders), Object[].class),
a.encoders()));
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.guards(a.guards());
b.matchers(a.matchers());
- value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- stringStream(a.path()).forEach(x -> b.path(x));
- value(a.value()).ifPresent(x -> b.path(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ strings(a.path()).forEach(x -> b.path(x));
+ string(a.value()).ifPresent(x -> b.path(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
index 0be1fae..8ba3d1c 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGetAnnotation.java
@@ -512,23 +512,23 @@ public class RestGetAnnotation {
b.set(REST_serializers,
merge(ConverterUtils.toType(b.peek(REST_serializers), Object[].class),
a.serializers()));
b.set(REST_encoders,
merge(ConverterUtils.toType(b.peek(REST_encoders), Object[].class),
a.encoders()));
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.converters(a.converters());
b.guards(a.guards());
b.matchers(a.matchers());
- value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- stringStream(a.path()).forEach(x -> b.path(x));
- value(a.value()).ifPresent(x -> b.path(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ strings(a.path()).forEach(x -> b.path(x));
+ string(a.value()).ifPresent(x -> b.path(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
index 2309d70..f13662b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOpAnnotation.java
@@ -613,30 +613,30 @@ public class RestOpAnnotation {
b.set(REST_serializers,
merge(ConverterUtils.toType(b.peek(REST_serializers), Object[].class),
a.serializers()));
b.set(REST_parsers,
merge(ConverterUtils.toType(b.peek(REST_parsers), Object[].class),
a.parsers()));
b.set(REST_encoders,
merge(ConverterUtils.toType(b.peek(REST_encoders), Object[].class),
a.encoders()));
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.consumes()).map(MediaType::of).forEach(x
-> b.consumes(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
- stringStream(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
- value(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.consumes()).map(MediaType::of).forEach(x ->
b.consumes(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
+ strings(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ string(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.converters(a.converters());
b.guards(a.guards());
b.matchers(a.matchers());
- value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- value(a.maxInput()).ifPresent(x -> b.maxInput(x));
- stringStream(a.path()).forEach(x -> b.path(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+ string(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ string(a.maxInput()).ifPresent(x -> b.maxInput(x));
+ strings(a.path()).forEach(x -> b.path(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
- value(a.method()).ifPresent(x -> b.httpMethod(x));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.method()).ifPresent(x -> b.httpMethod(x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
- String v = StringUtils.trim(string(a.value()));
+ String v =
StringUtils.trim(string(a.value()).orElse(null));
if (v != null) {
int i = v.indexOf(' ');
if (i == -1) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
index f1e84f3..e19b197 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostAnnotation.java
@@ -598,27 +598,27 @@ public class RestPostAnnotation {
b.set(REST_serializers,
merge(ConverterUtils.toType(b.peek(REST_serializers), Object[].class),
a.serializers()));
b.set(REST_parsers,
merge(ConverterUtils.toType(b.peek(REST_parsers), Object[].class),
a.parsers()));
b.set(REST_encoders,
merge(ConverterUtils.toType(b.peek(REST_encoders), Object[].class),
a.encoders()));
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.consumes()).map(MediaType::of).forEach(x
-> b.consumes(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
- stringStream(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
- value(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.consumes()).map(MediaType::of).forEach(x ->
b.consumes(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
+ strings(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ string(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.converters(a.converters());
b.guards(a.guards());
b.matchers(a.matchers());
- value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- value(a.maxInput()).ifPresent(x -> b.maxInput(x));
- stringStream(a.path()).forEach(x -> b.path(x));
- value(a.value()).ifPresent(x -> b.path(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ string(a.maxInput()).ifPresent(x -> b.maxInput(x));
+ strings(a.path()).forEach(x -> b.path(x));
+ string(a.value()).ifPresent(x -> b.path(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
index e759440..64fa2c6 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPutAnnotation.java
@@ -598,27 +598,27 @@ public class RestPutAnnotation {
b.set(REST_serializers,
merge(ConverterUtils.toType(b.peek(REST_serializers), Object[].class),
a.serializers()));
b.set(REST_parsers,
merge(ConverterUtils.toType(b.peek(REST_parsers), Object[].class),
a.parsers()));
b.set(REST_encoders,
merge(ConverterUtils.toType(b.peek(REST_encoders), Object[].class),
a.encoders()));
- value(a.contextClass()).ifPresent(x ->
b.contextClass(x));
- stringStream(a.produces()).map(MediaType::of).forEach(x
-> b.produces(x));
- stringStream(a.consumes()).map(MediaType::of).forEach(x
-> b.consumes(x));
- stringStream(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
- stringStream(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
- stringStream(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
- stringStream(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
- stringStream(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
- value(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
- value(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ type(a.contextClass()).ifPresent(x ->
b.contextClass(x));
+ strings(a.produces()).map(MediaType::of).forEach(x ->
b.produces(x));
+ strings(a.consumes()).map(MediaType::of).forEach(x ->
b.consumes(x));
+ strings(a.defaultRequestHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultRequestHeaders(x));
+ strings(a.defaultResponseHeaders()).map(x ->
stringHeader(x)).forEach(x -> b.defaultResponseHeaders(x));
+ strings(a.defaultRequestAttributes()).map(x ->
BasicNamedAttribute.ofPair(x)).forEach(x -> b.defaultRequestAttributes(x));
+ strings(a.defaultQueryData()).map(x ->
basicPart(x)).forEach(x -> b.defaultQueryData(x));
+ strings(a.defaultFormData()).map(x ->
basicPart(x)).forEach(x -> b.defaultFormData(x));
+ string(a.defaultAccept()).map(x ->
accept(x)).ifPresent(x -> b.defaultRequestHeaders(x));
+ string(a.defaultContentType()).map(x ->
contentType(x)).ifPresent(x -> b.defaultRequestHeaders(x));
b.converters(a.converters());
b.guards(a.guards());
b.matchers(a.matchers());
- value(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
-
value(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
- value(a.maxInput()).ifPresent(x -> b.maxInput(x));
- stringStream(a.path()).forEach(x -> b.path(x));
- value(a.value()).ifPresent(x -> b.path(x));
- cdStream(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
- value(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
-
value(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
+ string(a.clientVersion()).ifPresent(x ->
b.clientVersion(x));
+
string(a.defaultCharset()).map(Charset::forName).ifPresent(x ->
b.defaultCharset(x));
+ string(a.maxInput()).ifPresent(x -> b.maxInput(x));
+ strings(a.path()).forEach(x -> b.path(x));
+ string(a.value()).ifPresent(x -> b.path(x));
+ strings_cdl(a.rolesDeclared()).forEach(x ->
b.rolesDeclared(x));
+ string(a.roleGuard()).ifPresent(x -> b.roleGuard(x));
+
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
}
}
}
\ No newline at end of file