You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2019/11/20 10:51:52 UTC
[juneau] branch master updated: New @Bean(dictionary) annotation.
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 9c40c6e New @Bean(dictionary) annotation.
9c40c6e is described below
commit 9c40c6e4f749929d8be00d89e519c8e56cb1b5c3
Author: JamesBognar <ja...@apache.org>
AuthorDate: Wed Nov 20 05:51:36 2019 -0500
New @Bean(dictionary) annotation.
---
.../java/org/apache/juneau/BeanFilterTest.java | 4 +-
.../juneau/a/rttests/RoundTripBeanMapsTest.java | 8 ++--
.../a/rttests/RoundTripTransformBeansTest.java | 2 +-
.../juneau/dto/html5/Html5TemplateComboTest.java | 2 +-
.../java/org/apache/juneau/html/BasicHtmlTest.java | 14 +++---
.../apache/juneau/testutils/pojos/TypedBean.java | 2 +-
.../juneau/transforms/BeanDictionaryComboTest.java | 4 +-
.../java/org/apache/juneau/xml/BasicXmlTest.java | 16 +++----
.../apache/juneau/xml/XmlIgnoreCommentsTest.java | 16 +++----
.../java/org/apache/juneau/dto/html5/package.html | 2 +-
.../main/java/org/apache/juneau/BeanContext.java | 6 +--
.../src/main/java/org/apache/juneau/ClassMeta.java | 5 +-
.../java/org/apache/juneau/annotation/Bean.java | 14 ++++++
.../org/apache/juneau/parser/ParserSession.java | 2 +-
.../transform/AnnotationBeanFilterBuilder.java | 6 ++-
.../org/apache/juneau/transform/BeanFilter.java | 4 +-
.../apache/juneau/transform/BeanFilterBuilder.java | 55 ++++++++++++++++++++--
.../transform/InterfaceBeanFilterBuilder.java | 6 ++-
.../11.Transforms/03.AutoPojoSwaps.html | 2 +-
.../02.juneau-marshall/12.BeanDictionaries.html | 2 +-
.../12.BeanDictionaries/01.BeanSubTypes.html | 2 +-
.../21.XmlDetails/04.BeanTypeNameAnnotation.html | 14 +++---
.../apache/juneau/rest/testutils/TypedBean.java | 2 +-
23 files changed, 130 insertions(+), 60 deletions(-)
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/BeanFilterTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/BeanFilterTest.java
index e396f42..6741c7c 100755
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/BeanFilterTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/BeanFilterTest.java
@@ -52,7 +52,7 @@ public class BeanFilterTest {
assertEquals("f2", ((B2)a.fb).f2);
}
- @Bean(beanDictionary={A1.class, A2.class})
+ @Bean(dictionary={A1.class, A2.class})
public static abstract class A {
public String f0 = "f0";
public B fb;
@@ -68,7 +68,7 @@ public class BeanFilterTest {
public String f2;
}
- @Bean(beanDictionary={B1.class,B2.class})
+ @Bean(dictionary={B1.class,B2.class})
public static abstract class B {
public String f0b = "f0b";
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
index 7e4c3b9..5fa5126 100755
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
@@ -244,7 +244,7 @@ public class RoundTripBeanMapsTest extends RoundTripTest {
}
@Bean(
- beanDictionary={B1.class,B2.class,B3.class}
+ dictionary={B1.class,B2.class,B3.class}
)
public abstract static class B {
public String f0 = "f0";
@@ -352,7 +352,7 @@ public class RoundTripBeanMapsTest extends RoundTripTest {
public static class CFilter extends BeanFilterBuilder<C> {
public CFilter() {
- beanDictionary(CFilterDictionaryMap.class);
+ dictionary(CFilterDictionaryMap.class);
}
}
@@ -383,7 +383,7 @@ public class RoundTripBeanMapsTest extends RoundTripTest {
assertObjectEquals("{_type:'BA1',f0a:'f0a',f0b:'f0b',f1:'f1'}", b);
}
- @Bean(beanDictionary={BA1.class,BA2.class})
+ @Bean(dictionary={BA1.class,BA2.class})
public abstract static class BA {
public String f0a, f0b;
}
@@ -446,7 +446,7 @@ public class RoundTripBeanMapsTest extends RoundTripTest {
public static class CAFilter extends BeanFilterBuilder<CA> {
public CAFilter() {
- beanDictionary(CAFilterDictionaryMap.class);
+ dictionary(CAFilterDictionaryMap.class);
}
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripTransformBeansTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripTransformBeansTest.java
index 8347ec4..c7370f7 100755
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripTransformBeansTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripTransformBeansTest.java
@@ -274,7 +274,7 @@ public class RoundTripTransformBeansTest extends RoundTripTest {
}
- @Bean(beanDictionary={C3.class})
+ @Bean(dictionary={C3.class})
public static interface C1<T> extends Serializable {
void setF1(T f1);
T getF1();
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
index 5e61ee1..7b526c2 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
@@ -70,7 +70,7 @@ public class Html5TemplateComboTest extends ComboRoundTripTest {
}
- @Bean(beanDictionary=HtmlBeanDictionary.class)
+ @Bean(dictionary=HtmlBeanDictionary.class)
public static class FormTemplate {
private String action;
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/BasicHtmlTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/BasicHtmlTest.java
index 692b010..49fc93c 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/BasicHtmlTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/BasicHtmlTest.java
@@ -2768,7 +2768,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithTypeNames {
public B b1;
public Object b2;
@@ -2780,7 +2780,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithArrayTypeNames {
public B[] b1;
public Object[] b2;
@@ -2794,7 +2794,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWith2dArrayTypeNames {
public B[][] b1;
public Object[][] b2;
@@ -2808,7 +2808,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithMapTypeNames {
public Map<String,B> b1;
public Map<String,Object> b2;
@@ -2891,7 +2891,7 @@ public class BasicHtmlTest {
public String[] b;
}
- @Bean(beanDictionary={A.class},properties="a,ia,aa,o")
+ @Bean(dictionary={A.class},properties="a,ia,aa,o")
public static class BeanWithAbstractFields {
public A a;
public IA ia;
@@ -2907,7 +2907,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={A.class},properties="a,ia1,ia2,aa1,aa2,o1,o2")
+ @Bean(dictionary={A.class},properties="a,ia1,ia2,aa1,aa2,o1,o2")
public static class BeanWithAbstractArrayFields {
public A[] a;
public IA[] ia1, ia2;
@@ -2926,7 +2926,7 @@ public class BasicHtmlTest {
}
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractMapFields {
public Map<String,A> a;
public Map<String,AA> b;
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/pojos/TypedBean.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/pojos/TypedBean.java
index 7d36849..00fb157 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/pojos/TypedBean.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/pojos/TypedBean.java
@@ -12,6 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.testutils.pojos;
-@org.apache.juneau.annotation.Bean(beanDictionary={TypedBeanImpl.class})
+@org.apache.juneau.annotation.Bean(dictionary={TypedBeanImpl.class})
public interface TypedBean {
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
index 2a8ee28..b385ea8 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
@@ -864,7 +864,7 @@ public class BeanDictionaryComboTest extends ComboRoundTripTest {
return p.builder().build();
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static interface IA {}
@Bean(typeName="A")
@@ -877,7 +877,7 @@ public class BeanDictionaryComboTest extends ComboRoundTripTest {
}
}
- @Bean(beanDictionary={B.class}, typePropertyName="z")
+ @Bean(dictionary={B.class}, typePropertyName="z")
public static interface IB {}
@Bean(typeName="B")
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/BasicXmlTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/BasicXmlTest.java
index 2e6ab7a..7018fc4 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/BasicXmlTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/BasicXmlTest.java
@@ -1291,7 +1291,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithTypeNames {
public B b1;
public Object b2;
@@ -1303,7 +1303,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithArrayTypeNames {
public B[] b1;
public Object[] b2;
@@ -1317,7 +1317,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWith2dArrayTypeNames {
public B[][] b1;
public Object[][] b2;
@@ -1331,7 +1331,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithMapTypeNames {
public Map<String,B> b1;
public Map<String,Object> b2;
@@ -1558,7 +1558,7 @@ public class BasicXmlTest {
public String[] b;
}
- @Bean(beanDictionary={A.class},properties="a,ia,aa,o")
+ @Bean(dictionary={A.class},properties="a,ia,aa,o")
public static class BeanWithAbstractFields {
public A a;
public IA ia;
@@ -1574,7 +1574,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={A.class},properties="a,ia1,ia2,aa1,aa2,o1,o2")
+ @Bean(dictionary={A.class},properties="a,ia1,ia2,aa1,aa2,o1,o2")
public static class BeanWithAbstractArrayFields {
public A[] a;
public IA[] ia1, ia2;
@@ -1593,7 +1593,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractMapFields {
public Map<String,A> a;
public Map<String,AA> b;
@@ -1610,7 +1610,7 @@ public class BasicXmlTest {
}
}
- @Bean(beanDictionary={A.class},properties="a,ia,aa,o")
+ @Bean(dictionary={A.class},properties="a,ia,aa,o")
public static class BeanWithAbstractMapArrayFields {
public Map<String,A[]> a;
public Map<String,IA[]> ia;
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/XmlIgnoreCommentsTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/XmlIgnoreCommentsTest.java
index 5b53e36..37b87ae 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/XmlIgnoreCommentsTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/xml/XmlIgnoreCommentsTest.java
@@ -841,7 +841,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithTypeNames {
public B b1;
public Object b2;
@@ -853,7 +853,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithArrayTypeNames {
public B[] b1;
public Object[] b2;
@@ -867,7 +867,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWith2dArrayTypeNames {
public B[][] b1;
public Object[][] b2;
@@ -881,7 +881,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={B.class})
+ @Bean(dictionary={B.class})
public static class BeanWithPropertiesWithMapTypeNames {
public Map<String,B> b1;
public Map<String,Object> b2;
@@ -1108,7 +1108,7 @@ public class XmlIgnoreCommentsTest {
public String[] b;
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractFields {
public A a;
public IA ia;
@@ -1124,7 +1124,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractArrayFields {
public A[] a;
public IA[] ia1, ia2;
@@ -1143,7 +1143,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractMapFields {
public Map<String,A> a;
public Map<String,AA> b;
@@ -1160,7 +1160,7 @@ public class XmlIgnoreCommentsTest {
}
}
- @Bean(beanDictionary={A.class})
+ @Bean(dictionary={A.class})
public static class BeanWithAbstractMapArrayFields {
public Map<String,A[]> a;
public Map<String,IA[]> ia;
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html
index ab7d33f..1191096 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html
@@ -306,7 +306,7 @@
* A simple HTML form template whose serialized form is an HTML5 Form object.
* This time with parsing support.
*/</jd>
- <ja>@Bean</ja>(beanDictionary=HtmlBeanDictionary.<jk>class</jk>)
+ <ja>@Bean</ja>(dictionary=HtmlBeanDictionary.<jk>class</jk>)
<jk>public class</jk> FormTemplate {
<jk>private</jk> String <jf>action</jf>;
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 cb2f18b..cbf4442 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
@@ -243,7 +243,7 @@ public class BeanContext extends Context {
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
- * <li class='ja'>{@link Bean#beanDictionary()}
+ * <li class='ja'>{@link Bean#dictionary()}
* <li class='ja'>{@link Beanp#dictionary()}
* </ul>
* <li><b>Methods:</b>
@@ -254,7 +254,7 @@ public class BeanContext extends Context {
* <li class='jm'>{@link BeanContextBuilder#beanDictionaryReplace(Class...)}
* <li class='jm'>{@link BeanContextBuilder#beanDictionaryRemove(Object...)}
* <li class='jm'>{@link BeanContextBuilder#beanDictionaryRemove(Class...)}
- * <li class='jm'>{@link BeanFilterBuilder#beanDictionary(Class...)}
+ * <li class='jm'>{@link BeanFilterBuilder#dictionary(Class...)}
* </ul>
* </ul>
*
@@ -298,7 +298,7 @@ public class BeanContext extends Context {
*
* <jc>// Instead of by parser, define a bean dictionary on a class through an annotation.</jc>
* <jc>// This applies to all properties on this class and all subclasses.</jc>
- * <ja>@Bean</ja>(beanDictionary={Foo.<jk>class</jk>,Bar.<jk>class</jk>})
+ * <ja>@Bean</ja>(dictionary={Foo.<jk>class</jk>,Bar.<jk>class</jk>})
* <jk>public class</jk> MyBean {...}
*
* <jc>// Use the predefined HTML5 bean dictionary which is a BeanDictionaryList.</jc>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index b3e1de1..985cd07 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -339,6 +339,7 @@ public final class ClassMeta<T> implements Type {
Object example;
Mutater<String,T> stringMutater;
+ @SuppressWarnings("deprecation")
ClassMetaBuilder(Class<T> innerClass, BeanContext beanContext, Class<? extends T> implClass, BeanFilter beanFilter, PojoSwap<T,?>[] pojoSwaps, PojoSwap<?,?>[] childPojoSwaps, Object example) {
this.innerClass = innerClass;
this.beanContext = beanContext;
@@ -601,6 +602,8 @@ public final class ClassMeta<T> implements Type {
if (b != null) {
if (b.beanDictionary().length != 0)
beanRegistry = new BeanRegistry(beanContext, null, b.beanDictionary());
+ if (b.dictionary().length != 0)
+ beanRegistry = new BeanRegistry(beanContext, null, b.dictionary());
// This could be a non-bean POJO with a type name.
if (dictionaryName == null && ! b.typeName().isEmpty())
@@ -774,7 +777,7 @@ public final class ClassMeta<T> implements Type {
* Returns the bean registry for this class.
*
* <p>
- * This bean registry contains names specified in the {@link Bean#beanDictionary() @Bean(beanDictionary)} annotation
+ * This bean registry contains names specified in the {@link Bean#dictionary() @Bean(dictionary)} annotation
* defined on the class, regardless of whether the class is an actual bean.
* This allows interfaces to define subclasses with type names.
*
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 37e8ad1..bb6efc1 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
@@ -46,10 +46,24 @@ public @interface Bean {
* <ul class='seealso'>
* <li class='jf'>{@link BeanContext#BEAN_beanDictionary}
* </ul>
+ * @deprecated Use {@link #dictionary()}.
*/
+ @Deprecated
Class<?>[] beanDictionary() default {};
/**
+ * Bean dictionary.
+ *
+ * <p>
+ * The list of classes that make up the bean dictionary for all properties in this class and all subclasses.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanContext#BEAN_beanDictionary}
+ * </ul>
+ */
+ Class<?>[] dictionary() default {};
+
+ /**
* Specifies a list of properties that should be excluded from {@link BeanMap#entrySet()}.
*
* <h5 class='section'>Example:</h5>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
index f39be54..fc1b55f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -284,7 +284,7 @@ public abstract class ParserSession extends BeanSession {
return br.getClassMeta(typeName);
}
- // Resolve via @Bean(beanDictionary={}) on the expected type where the
+ // Resolve via @Bean(dictionary={}) on the expected type where the
// expected type is an interface with subclasses.
if (eType != null) {
br = eType.getBeanRegistry();
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
index ae8ff43..f587fc4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
@@ -37,6 +37,7 @@ public final class AnnotationBeanFilterBuilder<T> extends BeanFilterBuilder<T> {
* The {@link Bean @Bean} annotations found on the class and all parent classes in child-to-parent order.
* @throws Exception Thrown from property namer constructor.
*/
+ @SuppressWarnings("deprecation")
public AnnotationBeanFilterBuilder(Class<T> annotatedClass, List<Bean> annotations) throws Exception {
super(annotatedClass);
@@ -69,7 +70,10 @@ public final class AnnotationBeanFilterBuilder<T> extends BeanFilterBuilder<T> {
stopClass(b.stopClass());
if (b.beanDictionary().length > 0)
- beanDictionary(b.beanDictionary());
+ dictionary(b.beanDictionary());
+
+ if (b.dictionary().length > 0)
+ dictionary(b.dictionary());
if (b.propertyFilter() != PropertyFilter.class)
propertyFilter(b.propertyFilter());
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 2083911..94b9a66 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
@@ -57,9 +57,9 @@ public final class BeanFilter {
this.fluentSetters = builder.fluentSetters;
this.propertyNamer = castOrCreate(PropertyNamer.class, builder.propertyNamer);
this.beanDictionary =
- builder.beanDictionary == null
+ builder.dictionary == null
? null
- : builder.beanDictionary.toArray(new Class<?>[builder.beanDictionary.size()]);
+ : builder.dictionary.toArray(new Class<?>[builder.dictionary.size()]);
this.propertyFilter =
builder.propertyFilter == null
? PropertyFilter.DEFAULT
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 fd54c04..66e6829 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
@@ -62,7 +62,7 @@ public class BeanFilterBuilder<T> {
Class<?> interfaceClass, stopClass;
boolean sortProperties, fluentSetters;
Object propertyNamer;
- List<Class<?>> beanDictionary;
+ List<Class<?>> dictionary;
Object propertyFilter;
/**
@@ -501,19 +501,64 @@ public class BeanFilterBuilder<T> {
* </p>
*
* <ul class='seealso'>
- * <li class='ja'>{@link Bean#beanDictionary()}
+ * <li class='ja'>{@link Bean#dictionary()}
* <li class='jf'>{@link BeanContext#BEAN_beanDictionary}
* </ul>
*
* @param values
* The values to add to this property.
* @return This object (for method chaining).
+ * @deprecated Use {@link #dictionary(Class...)}.
*/
+ @Deprecated
public BeanFilterBuilder<T> beanDictionary(Class<?>...values) {
- if (beanDictionary == null)
- beanDictionary = new ArrayList<>(Arrays.asList(values));
+ if (dictionary == null)
+ dictionary = new ArrayList<>(Arrays.asList(values));
else for (Class<?> cc : values)
- beanDictionary.add(cc);
+ dictionary.add(cc);
+ return this;
+ }
+
+ /**
+ * Configuration property: Bean dictionary.
+ *
+ * <p>
+ * Adds to the list of classes that make up the bean dictionary for this bean.
+ *
+ * <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() {
+ * <jc>// Our bean contains generic collections of Foo and Bar objects.</jc>
+ * beanDictionary(Foo.<jk>class</jk>, Bar.<jk>class</jk>);
+ * }
+ * }
+ *
+ * <jc>// Register it with a parser.</jc>
+ * ReaderParser p = JsonParser
+ * .<jsm>create</jsm>()
+ * .beanFilters(MyFilter.<jk>class</jk>)
+ * .build();
+ *
+ * <jc>// Instantiate our bean.</jc>
+ * MyBean myBean = p.parse(json);
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link Bean#dictionary()}
+ * <li class='jf'>{@link BeanContext#BEAN_beanDictionary}
+ * </ul>
+ *
+ * @param values
+ * The values to add to this property.
+ * @return This object (for method chaining).
+ */
+ public BeanFilterBuilder<T> dictionary(Class<?>...values) {
+ if (dictionary == null)
+ dictionary = new ArrayList<>(Arrays.asList(values));
+ else for (Class<?> cc : values)
+ dictionary.add(cc);
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
index 78c7db0..36ddeaf 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
@@ -51,6 +51,7 @@ public class InterfaceBeanFilterBuilder<T> extends BeanFilterBuilder<T> {
init(interfaceClass);
}
+ @SuppressWarnings("deprecation")
private void init(Class<?> interfaceClass) {
interfaceClass(interfaceClass);
List<Bean> annotations = ClassInfo.of(interfaceClass).getAnnotations(Bean.class);
@@ -88,7 +89,10 @@ public class InterfaceBeanFilterBuilder<T> extends BeanFilterBuilder<T> {
stopClass(b.stopClass());
if (b.beanDictionary().length > 0)
- beanDictionary(b.beanDictionary());
+ dictionary(b.beanDictionary());
+
+ if (b.dictionary().length > 0)
+ dictionary(b.dictionary());
}
}
}
diff --git a/juneau-doc/docs/Topics/02.juneau-marshall/11.Transforms/03.AutoPojoSwaps.html b/juneau-doc/docs/Topics/02.juneau-marshall/11.Transforms/03.AutoPojoSwaps.html
index 0ccbb7b..fd89916 100644
--- a/juneau-doc/docs/Topics/02.juneau-marshall/11.Transforms/03.AutoPojoSwaps.html
+++ b/juneau-doc/docs/Topics/02.juneau-marshall/11.Transforms/03.AutoPojoSwaps.html
@@ -138,7 +138,7 @@ Auto-detected POJO swaps
* A simple HTML form template whose serialized form is an HTML5 Form object.
* This time with parsing support.
*/</jd>
- <ja>@Bean</ja>(beanDictionary=HtmlBeanDictionary.<jk>class</jk>)
+ <ja>@Bean</ja>(dictionary=HtmlBeanDictionary.<jk>class</jk>)
<jk>public class</jk> FormTemplate {
<jk>private</jk> String <jf>action</jf>;
diff --git a/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries.html b/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries.html
index 1f6afd2..e82745a 100644
--- a/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries.html
+++ b/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries.html
@@ -140,7 +140,7 @@ Bean Names and Dictionaries
be inherited by all subclasses.
</p>
<p class='bpcode w800'>
- <ja>@Bean</ja>(typePropertyName=<js>"mytype"</js>, beanDictionary={MyClass1.<jk>class</jk>,MyClass2.<jk>class</jk>})
+ <ja>@Bean</ja>(typePropertyName=<js>"mytype"</js>, dictionary={MyClass1.<jk>class</jk>,MyClass2.<jk>class</jk>})
<jk>public interface</jk> MyInterface {...}
<ja>@Bean</ja>(typeName=<js>"C1"</js>)
diff --git a/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries/01.BeanSubTypes.html b/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries/01.BeanSubTypes.html
index 05c98da..9ba8e59 100644
--- a/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries/01.BeanSubTypes.html
+++ b/juneau-doc/docs/Topics/02.juneau-marshall/12.BeanDictionaries/01.BeanSubTypes.html
@@ -32,7 +32,7 @@ Bean Subtypes
<p class='bpcode w800'>
<jc>// Abstract superclass</jc>
<ja>@Bean</ja>(
- beanDictionary={A1.<jk>class</jk>, A2.<jk>class</jk>}
+ dictionary={A1.<jk>class</jk>, A2.<jk>class</jk>}
)
<jk>public abstract class</jk> A {
<jk>public</jk> String <jf>f0</jf> = <js>"f0"</js>;
diff --git a/juneau-doc/docs/Topics/02.juneau-marshall/21.XmlDetails/04.BeanTypeNameAnnotation.html b/juneau-doc/docs/Topics/02.juneau-marshall/21.XmlDetails/04.BeanTypeNameAnnotation.html
index 806663c..c111052 100644
--- a/juneau-doc/docs/Topics/02.juneau-marshall/21.XmlDetails/04.BeanTypeNameAnnotation.html
+++ b/juneau-doc/docs/Topics/02.juneau-marshall/21.XmlDetails/04.BeanTypeNameAnnotation.html
@@ -140,7 +140,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={BeanX.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={BeanX.<jk>class</jk>})
<jk>class</jk> BeanWithArrayPropertiesWithTypeNames {
<jk>public</jk> BeanX[] b1 = <jk>new</jk> BeanX[]{
<jk>new</jk> BeanX()
@@ -175,7 +175,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={BeanX.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={BeanX.<jk>class</jk>})
<jk>class</jk> BeanWith2dArrayPropertiesWithTypeNames {
<jk>public</jk> BeanX[][] b1 = <jk>new</jk> BeanX[][]{{
<jk>new</jk> BeanX()
@@ -216,7 +216,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={BeanX.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={BeanX.<jk>class</jk>})
<jk>class</jk> BeanWithMapPropertiesWithTypeNames {
<jk>public</jk> Map<String,BeanX> b1 = <jk>new</jk> HashMap<>() {{
put(<js>"k1"</js>, <jk>new</jk> BeanX());
@@ -253,7 +253,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={A.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={A.<jk>class</jk>})
<jk>class</jk> BeanWithAbstractFields {
<jk>public</jk> A a = <jk>new</jk> A();
<jk>public</jk> IA ia = <jk>new</jk> A();
@@ -289,7 +289,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={A.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={A.<jk>class</jk>})
<jk>class</jk> BeanWithAbstractArrayFields {
<jk>public</jk> A[] a = <jk>new</jk> A[]{<jk>new</jk> A()};
<jk>public</jk> IA[] ia1 = <jk>new</jk> A[]{<jk>new</jk> A()};
@@ -342,7 +342,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={A.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={A.<jk>class</jk>})
<jk>class</jk> BeanWithAbstractMapFields {
<jk>public</jk> Map<String,A> a = <jk>new</jk> HashMap<>() {{
put(<js>"k1"</js>, <jk>new</jk> A());
@@ -377,7 +377,7 @@
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(beanDictionary={A.<jk>class</jk>})
+ <ja>@Bean</ja>(dictionary={A.<jk>class</jk>})
<jk>class</jk> BeanWithAbstractMapArrayFields {
<jk>public</jk> Map<String,A[]> a = <jk>new</jk> LinkedHashMap<>() {{
put(<js>"a1"</js>, <jk>new</jk> A[]{<jk>new</jk> A()});
diff --git a/juneau-rest/juneau-rest-mock-utest/src/test/java/org/apache/juneau/rest/testutils/TypedBean.java b/juneau-rest/juneau-rest-mock-utest/src/test/java/org/apache/juneau/rest/testutils/TypedBean.java
index c95fa24..078ce88 100644
--- a/juneau-rest/juneau-rest-mock-utest/src/test/java/org/apache/juneau/rest/testutils/TypedBean.java
+++ b/juneau-rest/juneau-rest-mock-utest/src/test/java/org/apache/juneau/rest/testutils/TypedBean.java
@@ -12,6 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.testutils;
-@org.apache.juneau.annotation.Bean(beanDictionary={TypedBeanImpl.class})
+@org.apache.juneau.annotation.Bean(dictionary={TypedBeanImpl.class})
public interface TypedBean {
}
\ No newline at end of file