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 4bd42c5d94 Marshall module improvements
4bd42c5d94 is described below
commit 4bd42c5d945cd87c2de9033c290c7bb4c8cd9724
Author: James Bognar <[email protected]>
AuthorDate: Sat Dec 6 18:26:37 2025 -0500
Marshall module improvements
---
.../src/main/java/org/apache/juneau/BeanMeta.java | 23 ++++++++++++++++++++++
.../main/java/org/apache/juneau/BeanSession.java | 7 ++++++-
.../src/main/java/org/apache/juneau/ClassMeta.java | 15 --------------
3 files changed, 29 insertions(+), 16 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
index 2b435ee78a..0e2a51030e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
@@ -961,6 +961,29 @@ public class BeanMeta<T> {
*/
public final String getDictionaryName() { return dictionaryName; }
+ /**
+ * Returns the type property name for this bean.
+ *
+ * <p>
+ * This is the name of the bean property used to store the dictionary
name of a bean type so that the parser knows
+ * the data type to reconstruct.
+ *
+ * <p>
+ * If <jk>null</jk>, <js>"_type"</js> should be assumed.
+ *
+ * <p>
+ * The value is determined from:
+ * <ul>
+ * <li>The {@link Bean#typePropertyName() @Bean(typePropertyName)}
annotation on the class, if present.
+ * <li>Otherwise, the default value from {@link
BeanContext#getBeanTypePropertyName()}.
+ * </ul>
+ *
+ * @return
+ * The type property name associated with this bean, or
<jk>null</jk> if the default <js>"_type"</js> should be used.
+ * @see BeanContext#getBeanTypePropertyName()
+ */
+ public final String getTypePropertyName() { return typePropertyName; }
+
/**
* Returns metadata about the specified property.
*
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 91d083c0aa..1e553f5a81 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
@@ -588,7 +588,12 @@ public class BeanSession extends ContextSession {
* @return The type property name. Never <jk>null</jk>.
*/
public final String getBeanTypePropertyName(ClassMeta cm) {
- var s = cm == null ? null : cm.getBeanTypePropertyName();
+ if (cm == null)
+ return getBeanTypePropertyName();
+ var beanMeta = cm.getBeanMeta();
+ if (beanMeta == null)
+ return getBeanTypePropertyName();
+ var s = beanMeta.getTypePropertyName();
return s == null ? getBeanTypePropertyName() : s;
}
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 e1d0cb96e9..6a8634a6c3 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
@@ -173,7 +173,6 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
private final OptionalSupplier<ConstructorInfo> stringConstructor;
// The X(String) constructor (if
it has one).
private final ObjectSwap<T,?>[] swaps;
// The object POJO swaps associated
with this bean (if it has any).
private final Map<Class<?>,Mutater<T,?>> toMutaters = new
ConcurrentHashMap<>();
- private final String typePropertyName;
// The property name of the _type
property for this class and subclasses.
private final ClassMeta<?> valueType;
// If MAP, the value class type.
/**
@@ -337,7 +336,6 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
_swaps.add((ObjectSwap<T,?>)ds);
this.swaps = _swaps.isEmpty() ? null :
_swaps.toArray(new ObjectSwap[_swaps.size()]);
- this.typePropertyName = opt(beanMeta).map(x2 ->
x2.typePropertyName).orElse(null);
this.proxyInvocationHandler = ()->(nn(beanMeta) &&
beanContext.isUseInterfaceProxies() && isInterface()) ? new
BeanProxyInvocationHandler<>(beanMeta) : null;
this.beanRegistry = _beanRegistry.get();
@@ -368,7 +366,6 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
this.valueType = null;
this.proxyInvocationHandler = null;
this.beanMeta = null;
- this.typePropertyName = null;
this.notABeanReason = null;
this.swaps = null;
this.beanRegistry = null;
@@ -408,7 +405,6 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
this.valueType = valueType;
this.proxyInvocationHandler = mainType.proxyInvocationHandler;
this.beanMeta = mainType.beanMeta;
- this.typePropertyName = mainType.typePropertyName;
this.notABeanReason = mainType.notABeanReason;
this.swaps = mainType.swaps;
this.beanRegistry = mainType.beanRegistry;
@@ -565,17 +561,6 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
public BeanRegistry getBeanRegistry() { return beanRegistry; }
- /**
- * Returns the type property name associated with this class and
subclasses.
- *
- * <p>
- * If <jk>null</jk>, <js>"_type"</js> should be assumed.
- *
- * @return
- * The type property name associated with this bean class, or
<jk>null</jk> if there is no explicit type
- * property name defined or this isn't a bean.
- */
- public String getBeanTypePropertyName() { return typePropertyName; }
/**
* Returns the builder swap associated with this class.