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 6672385e8b Marshall module improvements
6672385e8b is described below
commit 6672385e8bb38b3034e1363668f1042f59348a6f
Author: James Bognar <[email protected]>
AuthorDate: Mon Dec 8 14:27:42 2025 -0500
Marshall module improvements
---
.../src/main/java/org/apache/juneau/ClassMeta.java | 14 +++++++++-----
.../java/org/apache/juneau/html/HtmlSerializerSession.java | 6 +++---
.../org/apache/juneau/serializer/SerializerSession.java | 4 ++--
.../java/org/apache/juneau/xml/XmlBeanPropertyMeta.java | 4 ++--
.../java/org/apache/juneau/xml/XmlSerializerSession.java | 6 +++---
5 files changed, 19 insertions(+), 15 deletions(-)
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 0645b11760..efc4c74479 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
@@ -145,7 +145,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
private final Cache<Class<?>,ObjectSwap<?,?>> childSwapMap;
// Maps normal subclasses to ObjectSwaps.
private final Supplier<List<ObjectSwap<?,?>>> childSwaps;
// Any ObjectSwaps where the normal type is a subclass of this class.
private final Cache<Class<?>,ObjectSwap<?,?>> childUnswapMap;
// Maps swap subclasses to ObjectSwaps.
- private final Supplier<String> dictionaryName;
// The dictionary name of this class if it has one.
+ private final Supplier<String> beanDictionaryName;
// The dictionary name of this class if it has one.
private final Supplier<ClassMeta<?>> elementType;
// If ARRAY or COLLECTION, the element class type.
private final OptionalSupplier<String> example;
// Example JSON.
private final OptionalSupplier<FieldInfo> exampleField;
// The @Example-annotated field (if it has one).
@@ -244,7 +244,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
childSwapMap =
Cache.<Class<?>,ObjectSwap<?,?>>create().supplier(x -> findSwap(x)).build();
childSwaps = memoize(()->findChildSwaps());
childUnswapMap =
Cache.<Class<?>,ObjectSwap<?,?>>create().supplier(x -> findUnswap(x)).build();
- dictionaryName = memoize(()->findBeanDictionaryName());
+ beanDictionaryName =
memoize(()->findBeanDictionaryName());
elementType = memoize(()->findElementType());
enumValues = memoize(()->findEnumValues());
example = memoize(()->findExample());
@@ -304,7 +304,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
this.example = memoize(()->findExample());
this.implClass = memoize(()->findImplClass());
this.enumValues = memoize(()->findEnumValues());
- this.dictionaryName = memoize(()->findBeanDictionaryName());
+ this.beanDictionaryName = memoize(()->findBeanDictionaryName());
}
/**
@@ -339,7 +339,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
this.example = mainType.example;
this.implClass = mainType.implClass;
this.enumValues = mainType.enumValues;
- this.dictionaryName = mainType.dictionaryName;
+ this.beanDictionaryName = mainType.beanDictionaryName;
}
/**
@@ -506,7 +506,9 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
* The type name associated with this bean class, or <jk>null</jk>
if there is no type name defined or this
* isn't a bean.
*/
- public String getDictionaryName() { return dictionaryName.get(); }
+ public String getBeanDictionaryName() {
+ return beanDictionaryName.get();
+ }
/**
* For array and {@code Collection} types, returns the class type of
the components of the array or
@@ -1306,6 +1308,8 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
if (nn(d))
return d;
+ // Note that @Bean(typeName) can be defined on non-bean types,
so
+ // we have to check again.
return beanContext.getAnnotationProvider().find(Bean.class,
this)
.stream()
.map(AnnotationInfo::inner)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
index d05dca7f2e..001cb34689 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
@@ -485,7 +485,7 @@ public class HtmlSerializerSession extends
XmlSerializerSession {
var type2 = (String)null;
if (sType != eType)
- type2 = sType.getDictionaryName();
+ type2 = sType.getBeanDictionaryName();
if (type2 == null)
type2 = "array";
@@ -524,7 +524,7 @@ public class HtmlSerializerSession extends
XmlSerializerSession {
}
out.oTag(i + 1, "tr");
- String typeName = (cm == null ? null :
cm.getDictionaryName());
+ String typeName = (cm == null ? null :
cm.getBeanDictionaryName());
String typeProperty =
getBeanTypePropertyName(cm);
if (nn(typeName) && eType.getElementType() !=
cm)
@@ -852,7 +852,7 @@ public class HtmlSerializerSession extends
XmlSerializerSession {
var typeName = (String)null;
if (isAddBeanTypes() && ! eType.equals(aType))
- typeName = aType.getDictionaryName();
+ typeName = aType.getBeanDictionaryName();
// Swap if necessary
ObjectSwap swap = aType.getSwap(this);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index d350bda9d8..d5c1cac0f9 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -778,10 +778,10 @@ public class SerializerSession extends
BeanTraverseSession {
if (eType == aType || ! (isAddBeanTypes() || (session.isRoot()
&& isAddRootType())))
return null;
- String eTypeTn = eType.getDictionaryName();
+ String eTypeTn = eType.getBeanDictionaryName();
// First see if it's defined on the actual type.
- String tn = aType.getDictionaryName();
+ String tn = aType.getBeanDictionaryName();
if (nn(tn) && ! tn.equals(eTypeTn)) {
return tn;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanPropertyMeta.java
index 528ad46887..f453a5edfb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanPropertyMeta.java
@@ -125,14 +125,14 @@ public class XmlBeanPropertyMeta extends
ExtendedBeanPropertyMeta {
if (cen.isEmpty() && nn(xmlMetaProvider))
cen =
xmlMetaProvider.getXmlClassMeta(cmProperty).getChildName();
if (cen == null || cen.isEmpty())
- cen =
cmProperty.getElementType().getDictionaryName();
+ cen =
cmProperty.getElementType().getBeanDictionaryName();
if (cen == null || cen.isEmpty())
cen = name;
} else {
throw bex(cmBean.inner(), "Annotation error on
property ''{0}''. @Xml.format=COLLAPSED can only be specified on collections
and arrays.", name);
}
if (cen.isEmpty() && isCollection)
- cen = cmProperty.getDictionaryName();
+ cen = cmProperty.getBeanDictionaryName();
}
if (! cen.isEmpty())
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index d5d51f36ae..03d0de033b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -812,13 +812,13 @@ public class XmlSerializerSession extends
WriterSerializerSession {
isExpectedType = false;
}
- var resolvedDictionaryName = isExpectedType ? null :
aType.getDictionaryName();
+ var resolvedDictionaryName = isExpectedType ? null :
aType.getBeanDictionaryName();
// Note that the dictionary name may be specified on the actual
type or the serialized type.
// HTML templates will have them defined on the serialized type.
- var dictionaryName = aType.getDictionaryName();
+ var dictionaryName = aType.getBeanDictionaryName();
if (dictionaryName == null)
- dictionaryName = sType.getDictionaryName();
+ dictionaryName = sType.getBeanDictionaryName();
// char '\0' is interpreted as null.
if (nn(o) && sType.isChar() && ((Character)o).charValue() == 0)