JUNEAU-155 Split bpi/bpx into serializer and parser configuration
properties.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index bbd653d..3e7c42a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -24,9 +24,7 @@
import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
-import org.apache.juneau.marshall.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -865,8 +863,130 @@
*/
public static final String BEAN_bpx = PREFIX + ".bpx.sms";
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * <h5 class='section'>Property:</h5>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.bpro.sms"</js>
+ * <li><b>Data type:</b> <c>Map<String,String></c>
+ * <li><b>Default:</b> <c>{}</c>
+ * <li><b>Session property:</b> <jk>false</jk>
+ * <li><b>Annotations:</b>
+ * <ul>
+ * <li class='ja'>{@link Bean#bpro()}
+ * <li class='ja'>{@link Beanp#ro()}
+ * </ul>
+ * <li><b>Methods:</b>
+ * <ul>
+ * <li class='jm'>{@link BeanContextBuilder#bpro(Class, String)}
+ * <li class='jm'>{@link BeanContextBuilder#bpro(String, String)}
+ * <li class='jm'>{@link BeanContextBuilder#bpro(Map)}
+ * <li class='jm'>{@link BeanFilterBuilder#bpro(String...)}
+ * </ul>
+ * </ul>
+ *
+ * <h5 class='section'>Description:</h5>
+ * <p>
+ * Specifies one or more properties on a bean that are read-only despite having valid getters.
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <p>
+ * The keys are either fully-qualified or simple class names, and the values are comma-delimited lists of property
+ * names.
+ * The key <js>"*"</js> means all bean classes.
+ *
+ * <p>
+ * For example, <code>{Bean1:<js>'foo,bar'</js>}</code> means the <c>foo</c> and
+ * <c>bar</c> properties on any beans whose simple class name is <c>Bean1</c>.
+ *
+ * <p>
+ * Setting applies to specified class and all subclasses.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Create a parser that excludes the 'foo' and 'bar' properties on the MyBean class.</jc>
+ * ReaderParser p = JsonParser
+ * .<jsm>create</jsm>()
+ * .bpro(MyBean.<jk>class</jk>, <js>"foo,bar"</js>)
+ * .build();
+ *
+ * <jc>// Same, but use property.</jc>
+ * ReaderParser p = JsonParser
+ * .<jsm>create</jsm>()
+ * .addTo(<jsf>BEAN_bpro</jsf>, MyBean.<jk>class</jk>.getName(), <js>"foo,bar"</js>)
+ * .build();
+ *
+ * <jc>// Alternate using JSON object.</jc>
+ * ReaderParser p = JsonParser
+ * .<jsm>create</jsm>()
+ * .addTo(<jsf>BEAN_bpro</jsf>, <js>"{'org.apache.MyBean':'foo,bar'}"</js>)
+ * .build();
+ * </p>
+ */
public static final String BEAN_bpro = PREFIX + ".bpro.sms";
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * <h5 class='section'>Property:</h5>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.bpwo.sms"</js>
+ * <li><b>Data type:</b> <c>Map<String,String></c>
+ * <li><b>Default:</b> <c>{}</c>
+ * <li><b>Session property:</b> <jk>false</jk>
+ * <li><b>Annotations:</b>
+ * <ul>
+ * <li class='ja'>{@link Bean#bpwo()}
+ * <li class='ja'>{@link Beanp#wo()}
+ * </ul>
+ * <li><b>Methods:</b>
+ * <ul>
+ * <li class='jm'>{@link BeanContextBuilder#bpwo(Class, String)}
+ * <li class='jm'>{@link BeanContextBuilder#bpwo(String, String)}
+ * <li class='jm'>{@link BeanContextBuilder#bpwo(Map)}
+ * <li class='jm'>{@link BeanFilterBuilder#bpwo(String...)}
+ * </ul>
+ * </ul>
+ *
+ * <h5 class='section'>Description:</h5>
+ * <p>
+ * Specifies one or more properties on a bean that are write-only despite having valid setters.
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <p>
+ * The keys are either fully-qualified or simple class names, and the values are comma-delimited lists of property
+ * names.
+ * The key <js>"*"</js> means all bean classes.
+ *
+ * <p>
+ * For example, <code>{Bean1:<js>'foo,bar'</js>}</code> means the <c>foo</c> and
+ * <c>bar</c> properties on any beans whose simple class name is <c>Bean1</c>.
+ *
+ * <p>
+ * Setting applies to specified class and all subclasses.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Create a serializer that excludes the 'foo' and 'bar' properties on the MyBean class.</jc>
+ * WriterSerializer s = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .bpwo(MyBean.<jk>class</jk>, <js>"foo,bar"</js>)
+ * .build();
+ *
+ * <jc>// Same, but use property.</jc>
+ * WriterSerializer s = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .addTo(<jsf>BEAN_bpwo</jsf>, MyBean.<jk>class</jk>.getName(), <js>"foo,bar"</js>)
+ * .build();
+ *
+ * <jc>// Alternate using JSON object.</jc>
+ * WriterSerializer s = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .addTo(<jsf>BEAN_bpwo</jsf>, <js>"{'org.apache.MyBean':'foo,bar'}"</js>)
+ * .build();
+ * </p>
+ */
public static final String BEAN_bpwo = PREFIX + ".bpwo.sms";
/**
@@ -3032,10 +3152,23 @@
return emptySet();
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * @see #BEAN_bpro
+ * @return
+ * The list of read-only property names keyed by class name.
+ */
protected final Map<String,Set<String>> getBpro() {
return bpro;
}
+ /**
+ * Returns the {@link #BEAN_bpro} setting for the specified class.
+ *
+ * @param c The class.
+ * @return The read-only properties for the specified class, or an empty set if it's not defined for the class.
+ */
protected Set<String> getBpro(Class<?> c) {
if (bpro.isEmpty())
return emptySet();
@@ -3052,10 +3185,23 @@
return emptySet();
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * @see #BEAN_bpwo
+ * @return
+ * The list of write-only property names keyed by class name.
+ */
protected final Map<String,Set<String>> getBpwo() {
return bpwo;
}
+ /**
+ * Returns the {@link #BEAN_bpwo} setting for the specified class.
+ *
+ * @param c The class.
+ * @return The write-only properties for the specified class, or an empty set if it's not defined for the class.
+ */
protected Set<String> getBpwo(Class<?> c) {
if (bpwo.isEmpty())
return emptySet();
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
index 7807672..b1209ff 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
@@ -727,26 +727,114 @@
return addTo(BEAN_bpx, beanClassName, value);
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * <p>
+ * Specifies the read-only properties for the specified bean class.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ *
+ * @param beanClass The bean class.
+ * @param properties Comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpro(Class<?> beanClass, String properties) {
return addTo(BEAN_bpro, beanClass.getName(), properties);
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * <p>
+ * Specifies the read-only properties for the specified bean classes.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ *
+ * @param values
+ * The new value for this property.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpro(Map<String,String> values) {
return set(BEAN_bpro, values);
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * <p>
+ * Specifies the read-only properties for the specified bean class.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ *
+ * @param beanClassName
+ * The bean class name.
+ * <br>Can be a simple name, fully-qualified name, or <js>"*"</js> for all bean classes.
+ * @param value Comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpro(String beanClassName, String value) {
return addTo(BEAN_bpro, beanClassName, value);
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * <p>
+ * Specifies the write-only properties for the specified bean class.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ *
+ * @param beanClass The bean class.
+ * @param properties Comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpwo(Class<?> beanClass, String properties) {
return addTo(BEAN_bpwo, beanClass.getName(), properties);
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * <p>
+ * Specifies the write-only properties for the specified bean classes.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ *
+ * @param values
+ * The new value for this property.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpwo(Map<String,String> values) {
return set(BEAN_bpwo, values);
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * <p>
+ * Specifies the write-only properties for the specified bean class.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ *
+ * @param beanClassName
+ * The bean class name.
+ * <br>Can be a simple name, fully-qualified name, or <js>"*"</js> for all bean classes.
+ * @param value Comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanContextBuilder bpwo(String beanClassName, String value) {
return addTo(BEAN_bpwo, beanClassName, value);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index f94f15b..ea67725 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -1297,10 +1297,24 @@
return ctx.getBpx();
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * @see BeanContext#BEAN_bpro
+ * @return
+ * The list of read-only property names keyed by class name.
+ */
protected final Map<String,Set<String>> getBpro() {
return ctx.getBpro();
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * @see BeanContext#BEAN_bpwo
+ * @return
+ * The list of write-only property names keyed by class name.
+ */
protected final Map<String,Set<String>> getBpwo() {
return ctx.getBpwo();
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java
index 06ccfdb..f967405 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java
@@ -83,7 +83,7 @@
String bpi() default "";
/**
- * Bean property excludes
+ * Bean property excludes.
*
* <p>
* Specifies a list of properties that should be excluded from {@link BeanMap#entrySet()}.
@@ -101,8 +101,44 @@
*/
String bpx() default "";
+ /**
+ * Read-only bean properties.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are read-only despite having valid getters.
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Exclude the 'city' and 'state' properties from being parsed, but not serialized.</jc>
+ * <ja>@Bean</ja>(bpro=<js>"city,state"</js>})
+ * <jk>public class</jk> Address {...}
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ */
String bpro() default "";
+ /**
+ * Write-only bean properties.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are write-only despite having valid setters.
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Exclude the 'city' and 'state' properties from being serialized, but not parsed.</jc>
+ * <ja>@Bean</ja>(bpro=<js>"city,state"</js>})
+ * <jk>public class</jk> Address {...}
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ */
String bpwo() default "";
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
index f05681f..be61696 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
@@ -618,9 +618,162 @@
*/
CS[] bpxMap() default {};
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_bpro} property on all parsers.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are read-only despite having valid getters.
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Ignore 'a' and 'b' properties if they're present in the HTTP request body.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>POST</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bpro=<js>"MyBean: a,b"</js>)
+ * <jk>public void</jk> postMyBeans(List<MyBean> l) {...}
+ * </p>
+ *
+ * <ul class=''>
+ * <li>
+ * The format of each value is: <js>"Key: comma-delimited-tokens"</js>.
+ * <li>
+ * Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes.
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Semicolons can be used as an additional separator for multiple values:
+ * <p class='bcode w800'>
+ * <jc>// Equivalent</jc>
+ * bpro={<js>"Bean1: foo"</js>,<js>"Bean2: bar,baz"</js>}
+ * bpro=<js>"Bean1: foo; Bean2: bar,baz"</js>
+ * </p>
+ * <li>
+ * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
+ * <li>
+ * A default global value can be set via the system property <js>"BeanContext.bpro.sms"</js>.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ */
String[] bpro() default {};
+
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_bpro} property on all parsers.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are read-only despite having valid getters.
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Ignore 'a' and 'b' properties if they're present in the HTTP request body.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>POST</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bproMap={<ja>@CS</ja>(MyBean.<jk>class</jk>, <js>"a,b"</js>)})
+ * <jk>public void</jk> postMyBeans(List<MyBean> l) {...}
+ * </p>
+ *
+ * <ul class=''>
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
+ * <li>
+ * A default global value can be set via the system property <js>"BeanContext.bpro.sms"</js>.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ */
CS[] bproMap() default {};
+
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_bpwo} property on all serializers.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are write-only despite having valid setters.
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Ignore 'a' and 'b' properties when serializing the response body.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bpwo=<js>"MyBean: a,b"</js>)
+ * <jk>public</jk> List<MyBean> getMyBeans() {...}
+ * </p>
+ *
+ * <ul class=''>
+ * <li>
+ * The format of each value is: <js>"Key: comma-delimited-tokens"</js>.
+ * <li>
+ * Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes.
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Semicolons can be used as an additional separator for multiple values:
+ * <p class='bcode w800'>
+ * <jc>// Equivalent</jc>
+ * bpwo={<js>"Bean1: foo"</js>,<js>"Bean2: bar,baz"</js>}
+ * bpwo=<js>"Bean1: foo; Bean2: bar,baz"</js>
+ * </p>
+ * <li>
+ * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
+ * <li>
+ * A default global value can be set via the system property <js>"BeanContext.bpro.sms"</js>.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ */
String[] bpwo() default {};
+
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_bpwo} property on all serializers.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are write-only despite having valid setters.
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Ignore 'a' and 'b' properties if they're present in the HTTP request body.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bpwoMap={<ja>@CS</ja>(MyBean.<jk>class</jk>, <js>"a,b"</js>)})
+ * <jk>public void</jk> List<MyBean> getMyBeans() {...}
+ * </p>
+ *
+ * <ul class=''>
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
+ * <li>
+ * A default global value can be set via the system property <js>"BeanContext.bpro.sms"</js>.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ */
CS[] bpwoMap() default {};
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java
index 65b7f4e..f60b649 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java
@@ -323,7 +323,7 @@
* <ja>@Beanp</ja>(format=<js>"$%.2f"</js>)
* <jk>private float</jk> <jf>price</jf>;
*
- * <jk>public float</jk> gePrice() {
+ * <jk>public float</jk> getPrice() {
* <jk>return</jk> <jf>price</jf>;
* }
* }
@@ -331,6 +331,43 @@
*/
String format() default "";
+ /**
+ * Identifies a property as read-only.
+ *
+ * <p>
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jk>public class</jk> MyBean {
+ * <ja>@Beanp</ja>(ro=<js>"true"</js>)
+ * <jk>public float</jk> <jf>price</jf>;
+ * }
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ */
String ro() default "";
+
+ /**
+ * Identifies a property as write-only.
+ *
+ * <p>
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jk>public class</jk> MyBean {
+ * <ja>@Beanp</ja>(wo=<js>"true"</js>)
+ * <jk>public float</jk> <jf>price</jf>;
+ * }
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ */
String wo() default "";
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilter.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilter.java
index e76004c..ce39e6d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilter.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilter.java
@@ -100,7 +100,7 @@
* Returns the set and order of names of properties associated with a bean class.
*
* @return
- * The name of the properties associated with a bean class, or <jk>null</jk> if all bean properties should
+ * The names of the properties associated with a bean class, or and empty set if all bean properties should
* be used.
*/
public Set<String> getBpi() {
@@ -110,16 +110,26 @@
/**
* Returns the list of properties to ignore on a bean.
*
- * @return The name of the properties to ignore on a bean, or <jk>null</jk> to not ignore any properties.
+ * @return The names of the properties to ignore on a bean, or an empty set to not ignore any properties.
*/
public Set<String> getBpx() {
return bpx;
}
+ /**
+ * Returns the list of read-only properties on a bean.
+ *
+ * @return The names of the read-only properties on a bean, or an empty set to not have any read-only properties.
+ */
public Set<String> getBpro() {
return bpro;
}
+ /**
+ * Returns the list of write-only properties on a bean.
+ *
+ * @return The names of the write-only properties on a bean, or an empty set to not have any write-only properties.
+ */
public Set<String> getBpwo() {
return bpwo;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
index 9588b9f..cf2610f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
@@ -556,6 +556,43 @@
return this;
}
+ /**
+ * Configuration property: Read-only bean properties.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are read-only despite having valid getters.
+ * Serializers will serialize such properties as usual, but parsers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Define our filter.</jc>
+ * <jk>public class</jk> MyFilter <jk>extends</jk> BeanFilterBuilder<MyBean> {
+ * <jk>public</jk> MyFilter() {
+ * bpro(<js>"foo,bar"</js>);
+ * }
+ * }
+ *
+ * <jc>// Register it with a parser.</jc>
+ * ReaderParser p = JsonParser
+ * .<jsm>create</jsm>()
+ * .beanFilters(MyFilter.<jk>class</jk>)
+ * .build();
+ *
+ * <jc>// Parsers all properties except for 'foo' and 'bar'.</jc>
+ * MyBean b = p.parse(<js>"..."</js>, MyBean.<jk>class</jk>);
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link Bean#bpro()}
+ * <li class='ja'>{@link Beanp#ro()}
+ * <li class='jf'>{@link BeanContext#BEAN_bpro}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>Values can contain comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanFilterBuilder<T> bpro(String...value) {
this.bpro = new LinkedHashSet<>();
for (String v : value)
@@ -563,6 +600,43 @@
return this;
}
+ /**
+ * Configuration property: Write-only bean properties.
+ *
+ * <p>
+ * Specifies one or more properties on a bean that are write-only despite having valid setters.
+ * Parsers will parse such properties as usual, but serializers will silently ignore them.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Define our filter.</jc>
+ * <jk>public class</jk> MyFilter <jk>extends</jk> BeanFilterBuilder<MyBean> {
+ * <jk>public</jk> MyFilter() {
+ * bpwo(<js>"foo,bar"</js>);
+ * }
+ * }
+ *
+ * <jc>// Register it with a serializer.</jc>
+ * WriterSerializer s = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .beanFilters(MyFilter.<jk>class</jk>)
+ * .build();
+ *
+ * <jc>// Serializes all properties except for 'foo' and 'bar'.</jc>
+ * String json = s.serialize(<jk>new</jk> MyBean());
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link Bean#bpwo()}
+ * <li class='ja'>{@link Beanp#wo()}
+ * <li class='jf'>{@link BeanContext#BEAN_bpwo}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>Values can contain comma-delimited list of property names.
+ * @return This object (for method chaining).
+ */
public BeanFilterBuilder<T> bpwo(String...value) {
this.bpwo = new LinkedHashSet<>();
for (String v : value)
diff --git a/juneau-doc/docs/ReleaseNotes/8.1.2.html b/juneau-doc/docs/ReleaseNotes/8.1.2.html
index 9397603..3f0d65b 100644
--- a/juneau-doc/docs/ReleaseNotes/8.1.2.html
+++ b/juneau-doc/docs/ReleaseNotes/8.1.2.html
@@ -22,6 +22,18 @@
<h5 class='topic w800'>juneau-marshall</h5>
<ul class='spaced-list'>
<li>
+ Support for read-only and write-only properties.
+ <ul>
+ <li class='ja'>{@link oaja.Bean#bpro()}
+ <li class='ja'>{@link oaja.Bean#bpwo()}
+ <li class='ja'>{@link oaja.Beanp#ro()}
+ <li class='ja'>{@link oaja.Beanp#wo()}
+ <li class='jf'>{@link oaj.BeanContext#BEAN_bpro}
+ <li class='jf'>{@link oaj.BeanContext#BEAN_bpwo}
+ <li class='jm'>{@link oaj.BeanContextBuilder#bpro(Map)}
+ <li class='jm'>{@link oaj.BeanContextBuilder#bpwo(Map)}
+ </ul>
+ <li>
New convenience methods:
<ul>
<li class='jm'>{@link oaj.ObjectMap.parse(String)}