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 3bf78f7c1e Marshall module improvements
3bf78f7c1e is described below
commit 3bf78f7c1e1442145ccf39c9486222b9f016c74e
Author: James Bognar <[email protected]>
AuthorDate: Tue Dec 9 10:05:01 2025 -0500
Marshall module improvements
---
.../src/main/java/org/apache/juneau/BeanMeta.java | 38 +++++++++++++++++-----
1 file changed, 30 insertions(+), 8 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 a4431066a3..12495ac366 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
@@ -178,6 +178,14 @@ public class BeanMeta<T> {
return new BeanMetaValue<>(null, reason);
}
+ /**
+ * Represents a bean constructor with its associated property names.
+ *
+ * @param constructor The constructor information.
+ * @param propertyNames The list of property names that correspond to
the constructor parameters.
+ */
+ record BeanConstructor(Optional<ConstructorInfo> constructor,
List<String> args) {}
+
/*
* Temporary getter/setter method struct.
*/
@@ -476,6 +484,9 @@ public class BeanMeta<T> {
return beanFilter;
}
+ /** The constructor for this bean. */
+ protected final BeanConstructor constructor2;
+
/** The constructor for this bean. */
protected final ConstructorInfo constructor;
@@ -577,8 +588,6 @@ public class BeanMeta<T> {
.orElse(null);
}
-
-
/**
* Constructor.
*
@@ -896,6 +905,7 @@ public class BeanMeta<T> {
this.dynaProperty = dynaProperty.get();
this.constructor = constructor.get();
this.constructorArgs = constructorArgs.get();
+ this.constructor2 = new BeanConstructor(opt(constructor.get()),
l(constructorArgs.get()));
this.sortProperties = sortProperties;
this.typeProperty = BeanPropertyMeta.builder(this,
typePropertyName).canRead().canWrite().rawMetaType(ctx.string()).beanRegistry(beanRegistry.get()).build();
@@ -906,6 +916,18 @@ public class BeanMeta<T> {
beanProxyInvocationHandler =
memoize(()->ctx.isUseInterfaceProxies() && c.isInterface() ? new
BeanProxyInvocationHandler<>(this) : null);
}
+ protected boolean hasConstructor() {
+ return constructor2.constructor().isPresent();
+ }
+
+ protected ConstructorInfo getConstructor() {
+ return constructor2.constructor().orElse(null);
+ }
+
+ protected List<String> getConstructorArgs() {
+ return constructor2.args();
+ }
+
@Override /* Overridden from Object */
public boolean equals(Object o) {
return (o instanceof BeanMeta<?> o2) && eq(this, o2, (x, y) ->
eq(x.classMeta, y.classMeta));
@@ -1071,14 +1093,14 @@ public class BeanMeta<T> {
@SuppressWarnings("unchecked")
protected T newBean(Object outer) throws ExecutableException {
if (classMeta.isMemberClass() && classMeta.isNotStatic()) {
- if (nn(constructor))
- return constructor.<T>newInstance(outer);
+ if (hasConstructor())
+ return getConstructor().<T>newInstance(outer);
} else {
- if (nn(constructor))
- return constructor.<T>newInstance();
- InvocationHandler h =
classMeta.getProxyInvocationHandler();
+ if (hasConstructor())
+ return getConstructor().<T>newInstance();
+ var h = classMeta.getProxyInvocationHandler();
if (nn(h)) {
- ClassLoader cl =
classMeta.inner().getClassLoader();
+ var cl = classMeta.getClassLoader();
return (T)Proxy.newProxyInstance(cl,
a(classMeta.inner(), java.io.Serializable.class), h);
}
}