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 e2d6963 Clean up builders.
e2d6963 is described below
commit e2d696333c6adf006b04b3cfcb7a2df448055935
Author: JamesBognar <[email protected]>
AuthorDate: Sun Aug 8 09:02:08 2021 -0400
Clean up builders.
---
.../java/org/apache/juneau/ContextBuilder.java | 45 ++++++++++++++++++++--
.../apache/juneau/ContextPropertiesBuilder.java | 26 -------------
2 files changed, 42 insertions(+), 29 deletions(-)
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 66905a6..1216404 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
@@ -137,12 +137,27 @@ public abstract class ContextBuilder {
* </p>
*
* @param al The list of all annotations annotated with {@link
ContextApply}.
- * @param r The string resolver for resolving variables in annotation
values.
+ * @param vr The string resolver for resolving variables in annotation
values.
* @return This object (for method chaining).
*/
+ @SuppressWarnings({ "rawtypes", "unchecked" })
@FluentSetter
- public ContextBuilder applyAnnotations(AnnotationList al,
VarResolverSession r) {
- this.cpb.applyAnnotations(al, r);
+ public ContextBuilder applyAnnotations(AnnotationList al,
VarResolverSession vr) {
+ for (AnnotationInfo<?> ai : al.sort()) {
+ try {
+ for (ContextApplier ca : ai.getApplies(vr))
+ if (ca.canApply(this))
+ ca.apply(ai, this);
+ else if (ca.canApply(cpb))
+ ca.apply(ai, cpb);
+ else
+ throw new
ConfigException("Cannot apply annotation " + ca.getBuilderClass());
+ } catch (ConfigException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new ConfigException(ex, "Could not
instantiate ConfigApply class {0}", ai);
+ }
+ }
return this;
}
@@ -870,6 +885,30 @@ public abstract class ContextBuilder {
return this;
}
+ @SuppressWarnings("javadoc")
+ public ContextBuilder setIfNotEmpty(String name, Object value) {
+ cpb.setIfNotEmpty(name, value);
+ return this;
+ }
+
+ @SuppressWarnings("javadoc")
+ public ContextBuilder setIf(boolean b, String name, Object value) {
+ cpb.setIf(b, name, value);
+ return this;
+ }
+
+ @SuppressWarnings("javadoc")
+ public ContextBuilder appendToIfNotEmpty(String name, Object value) {
+ cpb.appendToIfNotEmpty(name, value);
+ return this;
+ }
+
+ @SuppressWarnings("javadoc")
+ public ContextBuilder addToIfNotEmpty(String name, Object value) {
+ cpb.addToIfNotEmpty(name, value);
+ return this;
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Helper methods.
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextPropertiesBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextPropertiesBuilder.java
index 705d7ce..b0ae717 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextPropertiesBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextPropertiesBuilder.java
@@ -27,8 +27,6 @@ import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.marshall.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.svl.*;
/**
* A builder for {@link ContextProperties} objects.
@@ -104,30 +102,6 @@ public class ContextPropertiesBuilder {
}
/**
- * Applies the settings in the specified annotations to this property
store.
- *
- * @param al The list of annotations to apply.
- * @param vr The string resolver used to resolve any variables in the
annotations.
- * @return This object (for method chaining).
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public ContextPropertiesBuilder applyAnnotations(AnnotationList al,
VarResolverSession vr) {
- vr = vr == null ? VarResolver.DEFAULT.createSession() : vr;
- for (AnnotationInfo<?> ai : al.sort()) {
- try {
- for (ContextApplier ca : ai.getApplies(vr))
- if (ca.canApply(this))
- ca.apply(ai, this);
- } catch (ConfigException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new ConfigException(ex, "Could not
instantiate ConfigApply class {0}", ai);
- }
- }
- return this;
- }
-
- /**
* Sets a configuration property value on this object.
*
* @param key The configuration property key (e.g
<js>"BeanContext.foo.ss/add.1"</js>).