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 ddfaf8dc6c Marshall module improvements
ddfaf8dc6c is described below
commit ddfaf8dc6c7e632d0109cafe9f266b2cab367973
Author: James Bognar <[email protected]>
AuthorDate: Wed Dec 10 12:05:19 2025 -0500
Marshall module improvements
---
.../java/org/apache/juneau/BeanPropertyMeta.java | 52 ++++++++++++----------
.../org/apache/juneau/internal/FilteredMap.java | 1 +
.../jsonschema/JsonSchemaGeneratorSession.java | 8 +++-
3 files changed, 35 insertions(+), 26 deletions(-)
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 aade93f219..2929add051 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
@@ -61,19 +61,19 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
* BeanPropertyMeta builder class.
*/
public static class Builder {
- BeanMeta<?> beanMeta;
- BeanContext bc;
- String name;
- Field field, innerField; // TODO - Replace with FieldInfo
fields
- Method getter, setter, extraKeys; // TODO - Replace with
MethodInfo fields
- boolean isConstructorArg, isUri, isDyna, isDynaGetterMap;
- ClassMeta<?> rawTypeMeta, typeMeta;
- String[] properties;
- ObjectSwap swap;
- BeanRegistry beanRegistry;
- Object overrideValue;
- BeanPropertyMeta delegateFor;
- boolean canRead, canWrite, readOnly, writeOnly;
+ BeanMeta<?> beanMeta; // Package-private for BeanMeta access
+ BeanContext bc; // Package-private for BeanMeta access
+ String name; // Package-private for BeanMeta access
+ Field field, innerField; // Package-private for BeanMeta
access. TODO - Replace with FieldInfo fields
+ Method getter, setter, extraKeys; // Package-private for
BeanMeta access. TODO - Replace with MethodInfo fields
+ private boolean isConstructorArg, isUri, isDyna,
isDynaGetterMap;
+ private ClassMeta<?> rawTypeMeta, typeMeta;
+ private List<String> properties;
+ private ObjectSwap swap;
+ private BeanRegistry beanRegistry;
+ private Object overrideValue;
+ private BeanPropertyMeta delegateFor;
+ private boolean canRead, canWrite, readOnly, writeOnly;
Builder(BeanMeta<?> beanMeta, String name) {
this.beanMeta = beanMeta;
@@ -240,7 +240,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (swap == null)
swap = getPropertySwap(x);
if (! x.properties().isEmpty())
- properties =
splita(x.properties());
+ properties =
split(x.properties());
addAll(bdClasses,
(Object[])x.dictionary());
if (! x.ro().isEmpty())
readOnly =
Boolean.valueOf(x.ro());
@@ -260,7 +260,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (swap == null)
swap = getPropertySwap(x);
if (nn(properties) && !
x.properties().isEmpty())
- properties =
splita(x.properties());
+ properties =
split(x.properties());
addAll(bdClasses,
(Object[])x.dictionary());
if (! x.ro().isEmpty())
readOnly =
Boolean.valueOf(x.ro());
@@ -279,7 +279,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (swap == null)
swap = getPropertySwap(x);
if (nn(properties) && !
x.properties().isEmpty())
- properties =
splita(x.properties());
+ properties =
split(x.properties());
addAll(bdClasses,
(Object[])x.dictionary());
if (! x.ro().isEmpty())
readOnly =
Boolean.valueOf(x.ro());
@@ -393,7 +393,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
private final ClassMeta<?> rawTypeMeta,
// The real class type of the bean property.
typeMeta; // The
transformed class type of the bean property.
- private final String[] properties; // The value
of the @Beanp(properties) annotation.
+ private final List<String> properties; // The
value of the @Beanp(properties) annotation (unmodifiable).
private final ObjectSwap swap; //
ObjectSwap defined only via @Beanp annotation.
private final BeanRegistry beanRegistry;
private final Object overrideValue; // The bean
property value (if it's an overridden delegate).
@@ -422,7 +422,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
name = b.name;
rawTypeMeta = b.rawTypeMeta;
typeMeta = b.typeMeta;
- properties = b.properties;
+ properties = b.properties == null ? null : u(b.properties);
swap = b.swap;
beanRegistry = b.beanRegistry;
overrideValue = b.overrideValue;
@@ -830,9 +830,9 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
* Returns the override list of properties defined through a {@link
Beanp#properties() @Beanp(properties)} annotation
* on this property.
*
- * @return The list of override properties, or <jk>null</jk> if
annotation not specified.
+ * @return An unmodifiable list of override properties, or
<jk>null</jk> if annotation not specified.
*/
- public String[] getProperties() { return properties; }
+ public List<String> getProperties() { return properties; }
/**
* Equivalent to calling {@link BeanMap#getRaw(Object)}, but is faster
since it avoids looking up the property meta.
@@ -935,11 +935,15 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
return null;
if (cm.isBean())
return new BeanMap(session, o, new
BeanMetaFiltered(cm.getBeanMeta(), properties));
- if (cm.isMap())
- return new FilteredMap(cm, (Map)o, properties);
+ if (cm.isMap()) {
+ var propsArray = properties == null ? null :
properties.toArray(new String[0]);
+ return new FilteredMap(cm, (Map)o, propsArray);
+ }
if (cm.isObject()) {
- if (o instanceof Map o2)
- return new FilteredMap(cm, o2, properties);
+ if (o instanceof Map o2) {
+ var propsArray = properties == null ? null :
properties.toArray(new String[0]);
+ return new FilteredMap(cm, o2, propsArray);
+ }
var bm = bc.getBeanMeta(o.getClass());
if (nn(bm))
return new BeanMap(session, o, new
BeanMetaFiltered(cm.getBeanMeta(), properties));
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
index 204adc044d..8314cdf20c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
@@ -65,6 +65,7 @@ public class FilteredMap<K,V> extends AbstractMap<K,V>
implements Delegate<Map<K
* @param innerMap The map being wrapped. Must not be <jk>null</jk>.
* @param keys The keys in the new map. Must not be <jk>null</jk>.
*/
+ // TODO - Convert keys to List<K>
public FilteredMap(ClassMeta<Map<K,V>> classMeta, Map<K,V> innerMap,
K[] keys) {
assertArgNotNull("innerMap", innerMap);
assertArgNotNull("keys", keys);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
index 6a9ec4c6ac..1a9ca2baa1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
@@ -302,6 +302,7 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
return null;
}
+ // TODO - Convert pNames to List<String>
@SuppressWarnings({ "unchecked", "rawtypes", "null" })
private JsonMap getSchema(ClassMeta<?> eType, String attrName, String[]
pNames, boolean exampleAdded, boolean descriptionAdded,
JsonSchemaBeanPropertyMeta jsbpm)
throws BeanRecursionException, SerializeException {
@@ -422,8 +423,11 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
bm = new BeanMetaFiltered(bm, pNames);
for (Iterator<BeanPropertyMeta> i =
bm.getProperties().values().iterator(); i.hasNext();) {
BeanPropertyMeta p = i.next();
- if (p.canRead())
- properties.put(p.getName(),
getSchema(p.getClassMeta(), p.getName(), p.getProperties(), exampleAdded,
descriptionAdded, getJsonSchemaBeanPropertyMeta(p)));
+ if (p.canRead()) {
+ var pProps = p.getProperties();
+ var pNamesArray = pProps ==
null ? null : pProps.toArray(new String[0]);
+ properties.put(p.getName(),
getSchema(p.getClassMeta(), p.getName(), pNamesArray, exampleAdded,
descriptionAdded, getJsonSchemaBeanPropertyMeta(p)));
+ }
}
out.put("properties", properties);