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 fb93bc20d1 Marshall module improvements
fb93bc20d1 is described below
commit fb93bc20d171b8716bb0c09542a8e84e4b9f604f
Author: James Bognar <[email protected]>
AuthorDate: Fri Dec 12 17:00:06 2025 -0500
Marshall module improvements
---
.../src/main/java/org/apache/juneau/BeanContext.java | 19 +++++++++++++------
.../java/org/apache/juneau/BeanPropertyMeta.java | 20 +++++++++++---------
.../src/main/java/org/apache/juneau/BeanSession.java | 2 +-
3 files changed, 25 insertions(+), 16 deletions(-)
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 d8c475b33d..4d7c4e450b 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
@@ -3713,24 +3713,31 @@ public class BeanContext extends Context {
* The class to resolve.
* @param type
* The class to resolve.
- * <br>Can be any of the following: {@link ClassMeta}, {@link
Class}, {@link ParameterizedType}, {@link GenericArrayType}
+ * <br>Can be any of the following: {@link ClassMeta}, {@link
ClassInfo}, {@link Class}, {@link ParameterizedType}, {@link GenericArrayType}
* @param args
* The type arguments of the class if it's a collection or map.
- * <br>Can be any of the following: {@link ClassMeta}, {@link
Class}, {@link ParameterizedType}, {@link GenericArrayType}
+ * <br>Can be any of the following: {@link ClassMeta}, {@link
ClassInfo}, {@link Class}, {@link ParameterizedType}, {@link GenericArrayType}
* <br>Ignored if the main type is not a map or collection.
* @return The resolved class meta.
*/
public final <T> ClassMeta<T> getClassMeta(Type type, Type...args) {
if (type == null)
return null;
- ClassMeta<T> cm = type instanceof Class type2 ?
getClassMeta(type2) : resolveClassMeta(type, null);
+ var cm = (ClassMeta<T>)null;
+ if (type instanceof Class type2)
+ cm = getClassMeta(type2);
+ else
+ cm = resolveClassMeta(type, null);
if (args.length == 0)
return cm;
- ClassMeta<?>[] cma = new ClassMeta[args.length + 1];
+ var cma = new ClassMeta<?>[args.length + 1];
cma[0] = cm;
- for (var i = 0; i < Array.getLength(args); i++) {
+ for (var i = 0; i < length(args); i++) {
var arg = (Type)Array.get(args, i);
- cma[i + 1] = arg instanceof Class arg2 ?
getClassMeta(arg2) : resolveClassMeta(arg, null);
+ if (arg instanceof Class arg2)
+ cma[i + 1] = getClassMeta(arg2);
+ else
+ cma[i + 1] = resolveClassMeta(arg, null);
}
return (ClassMeta<T>)getTypedClassMeta(cma, 0);
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index e8283d6250..69e7d93e52 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -140,13 +140,15 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
return this;
}
- private static ObjectSwap getPropertySwap(Beanp p) {
+ private static ObjectSwap beanpSwap(AnnotationInfo<Beanp> ai) {
+ var p = ai.inner();
if (! p.format().isEmpty())
return
BeanCreator.of(ObjectSwap.class).type(StringFormatSwap.class).arg(String.class,
p.format()).run();
return null;
}
- private static ObjectSwap getPropertySwap(Swap s) throws
RuntimeException {
+ private static ObjectSwap swapSwap(AnnotationInfo<Swap> ai)
throws RuntimeException {
+ var s = ai.inner();
var c = s.value();
if (isVoid(c))
c = s.impl();
@@ -297,7 +299,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
lp.forEach(x -> {
var beanp = x.inner();
if (swap == null)
- swap = getPropertySwap(beanp);
+ swap = beanpSwap(x);
if (isNotEmpty(beanp.properties()))
properties =
split(beanp.properties());
bdClasses.addAll(l(beanp.dictionary()));
@@ -306,7 +308,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (isNotEmpty(beanp.wo()))
writeOnly = b(beanp.wo());
});
- ap.find(Swap.class,
ifi).stream().map(AnnotationInfo::inner).findFirst().ifPresent(x -> swap =
getPropertySwap(x));
+ ap.find(Swap.class,
ifi).stream().findFirst().ifPresent(x -> swap = swapSwap(x));
isUri |= ap.has(Uri.class, ifi);
}
@@ -318,7 +320,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
lp.forEach(x -> {
var beanp = x.inner();
if (swap == null)
- swap = getPropertySwap(beanp);
+ swap = beanpSwap(x);
if (nn(properties) &&
isNotEmpty(beanp.properties()))
properties =
split(beanp.properties());
bdClasses.addAll(l(beanp.dictionary()));
@@ -327,7 +329,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (isNotEmpty(beanp.wo()))
writeOnly = b(beanp.wo());
});
- ap.find(Swap.class,
gi).stream().map(AnnotationInfo::inner).forEach(x -> swap = getPropertySwap(x));
+ ap.find(Swap.class, gi).stream().forEach(x ->
swap = swapSwap(x));
}
if (nn(setter)) {
@@ -338,7 +340,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
lp.forEach(x -> {
var beanp = x.inner();
if (swap == null)
- swap = getPropertySwap(beanp);
+ swap = beanpSwap(x);
if (nn(properties) &&
isNotEmpty(beanp.properties()))
properties =
split(beanp.properties());
bdClasses.addAll(l(beanp.dictionary()));
@@ -347,7 +349,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (isNotEmpty(beanp.wo()))
writeOnly = b(beanp.wo());
});
- ap.find(Swap.class,
si).stream().map(AnnotationInfo::inner).forEach(x -> swap = getPropertySwap(x));
+ ap.find(Swap.class, si).stream().forEach(x ->
swap = swapSwap(x));
}
if (rawTypeMeta == null)
@@ -406,7 +408,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
return false;
if (typeMeta == null)
- typeMeta = (nn(swap) ?
bc.getClassMeta(swap.getSwapClass().innerType()) : rawTypeMeta == null ?
bc.object() : rawTypeMeta);
+ typeMeta = (nn(swap) ?
bc.getClassMeta(swap.getSwapClass()) : rawTypeMeta == null ? bc.object() :
rawTypeMeta);
if (typeMeta == null)
typeMeta = rawTypeMeta;
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 c6ee73707c..bc41cf2997 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
@@ -1200,7 +1200,7 @@ public class BeanSession extends ContextSession {
var fc = swap.getSwapClass();
if (nc.isParentOf(tc) &&
fc.isParentOf(value.getClass()))
return (T)swap.unswap(this, value, to);
- var fcm = getClassMeta(fc.inner());
+ var fcm = getClassMeta(fc);
if (fcm.isNumber() && value instanceof Number
value2) {
value = convertToMemberType(null,
value2, fc.inner());
return (T)swap.unswap(this, value, to);