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 1650015436 Replace Mutaters with BasicConverter
1650015436 is described below
commit 1650015436803d22d944ff29352b7d3acde3da57
Author: James Bognar <[email protected]>
AuthorDate: Thu Apr 2 15:34:53 2026 -0700
Replace Mutaters with BasicConverter
---
.../main/java/org/apache/juneau/BeanContext.java | 41 ++++++++++------------
.../main/java/org/apache/juneau/BeanSession.java | 6 +++-
2 files changed, 23 insertions(+), 24 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 ba4ba41dba..cd4c0d65e3 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
@@ -256,9 +256,9 @@ public class BeanContext extends Context {
private List<ClassInfo> beanDictionary;
private List<Object> swaps;
private Set<ClassInfo> notBeanClasses;
-
private Set<String> notBeanPackages;
- private ConfigurableConverter converter;
+
+ private final ConfigurableConverter converter = new
ConfigurableConverter();
/**
* Constructor.
@@ -285,14 +285,14 @@ public class BeanContext extends Context {
ignoreInvocationExceptionsOnSetters =
env("BeanContext.ignoreInvocationExceptionsOnSetters", false);
ignoreUnknownBeanProperties =
env("BeanContext.ignoreUnknownBeanProperties", false);
ignoreUnknownEnumValues =
env("BeanContext.ignoreUnknownEnumValues", false);
- locale =
env("BeanContext.locale").map(Locale::forLanguageTag).orElse(Locale.getDefault());
- mediaType =
env("BeanContext.mediaType").map(MediaType::of).orElse(null);
- notBeanClasses = new TreeSet<>();
- notBeanPackages = new TreeSet<>();
- propertyNamer = null;
- sortProperties = env("BeanContext.sortProperties", false);
- swaps = list();
- timeZone =
env("BeanContext.timeZone").map(TimeZone::getTimeZone).orElse(null);
+ locale =
env("BeanContext.locale").map(Locale::forLanguageTag).orElse(Locale.getDefault());
+ mediaType =
env("BeanContext.mediaType").map(MediaType::of).orElse(null);
+ notBeanClasses = new TreeSet<>();
+ notBeanPackages = new TreeSet<>();
+ propertyNamer = null;
+ sortProperties = env("BeanContext.sortProperties",
false);
+ swaps = list();
+ timeZone =
env("BeanContext.timeZone").map(TimeZone::getTimeZone).orElse(null);
typePropertyName = env("BeanContext.typePropertyName",
"_type");
useEnumNames = env("BeanContext.useEnumNames", false);
useJavaBeanIntrospector =
env("BeanContext.useJavaBeanIntrospector", false);
@@ -314,7 +314,6 @@ public class BeanContext extends Context {
beansRequireDefaultConstructor =
copyFrom.beansRequireDefaultConstructor;
beansRequireSerializable =
copyFrom.beansRequireSerializable;
beansRequireSettersForGetters =
copyFrom.beansRequireSettersForGetters;
- converter = copyFrom.converter;
disableBeansRequireSomeProperties = !
copyFrom.beansRequireSomeProperties;
disableIgnoreMissingSetters = !
copyFrom.ignoreMissingSetters;
disableIgnoreTransientFields = !
copyFrom.ignoreTransientFields;
@@ -354,7 +353,6 @@ public class BeanContext extends Context {
beansRequireDefaultConstructor =
copyFrom.beansRequireDefaultConstructor;
beansRequireSerializable =
copyFrom.beansRequireSerializable;
beansRequireSettersForGetters =
copyFrom.beansRequireSettersForGetters;
- converter = copyFrom.converter;
disableBeansRequireSomeProperties =
copyFrom.disableBeansRequireSomeProperties;
disableIgnoreMissingSetters =
copyFrom.disableIgnoreMissingSetters;
disableIgnoreTransientFields =
copyFrom.disableIgnoreTransientFields;
@@ -427,8 +425,6 @@ public class BeanContext extends Context {
* @return This object.
*/
public <I, O> Builder addConverter(Class<I> inType, Class<O>
outType, Conversion<I, O> conversion) {
- if (converter == null)
- converter = new ConfigurableConverter();
converter.add(inType, outType, conversion);
return this;
}
@@ -2261,7 +2257,6 @@ public class BeanContext extends Context {
beanMethodVisibility,
beanFieldVisibility,
beanDictionary,
- converter != null ?
System.identityHashCode(converter) : 0,
swaps,
notBeanClasses,
notBeanPackages,
@@ -3747,17 +3742,17 @@ public class BeanContext extends Context {
var builderNotBeanClasses = new
ArrayList<>(builder.notBeanClasses);
notBeanClasses = builderNotBeanClasses.isEmpty() ?
DEFAULT_NOTBEAN_CLASSES : Stream.concat(builderNotBeanClasses.stream(),
DEFAULT_NOTBEAN_CLASSES.stream()).distinct().toList();
- List<String> notBeanPackagesList = notBeanPackages.isEmpty() ?
DEFAULT_NOTBEAN_PACKAGES : Stream.concat(notBeanPackages.stream(),
DEFAULT_NOTBEAN_PACKAGES.stream()).toList();
- LinkedHashSet<String> notBeanPackageNamesTemp =
notBeanPackagesList.stream().filter(x -> !
x.endsWith(".*")).collect(Collectors.toCollection(LinkedHashSet::new));
- notBeanPackageNames = u(notBeanPackageNamesTemp);
- notBeanPackagePrefixes = notBeanPackagesList.stream().filter(x ->
x.endsWith(".*")).map(x -> x.substring(0, x.length() - 2)).toList();
+ List<String> notBeanPackagesList = notBeanPackages.isEmpty() ?
DEFAULT_NOTBEAN_PACKAGES : Stream.concat(notBeanPackages.stream(),
DEFAULT_NOTBEAN_PACKAGES.stream()).toList();
+ LinkedHashSet<String> notBeanPackageNamesTemp =
notBeanPackagesList.stream().filter(x -> !
x.endsWith(".*")).collect(Collectors.toCollection(LinkedHashSet::new));
+ notBeanPackageNames = u(notBeanPackageNamesTemp);
+ notBeanPackagePrefixes = notBeanPackagesList.stream().filter(x
-> x.endsWith(".*")).map(x -> x.substring(0, x.length() - 2)).toList();
propertyNamerBean =
safe(()->propertyNamer.getDeclaredConstructor().newInstance());
- var objectSwapsList = new LinkedList<ObjectSwap<?,?>>();
- swaps.forEach(x -> {
- if (x instanceof ObjectSwap<?,?> os) {
- objectSwapsList.add(os);
+ var objectSwapsList = new LinkedList<ObjectSwap<?,?>>();
+ swaps.forEach(x -> {
+ if (x instanceof ObjectSwap<?,?> os) {
+ objectSwapsList.add(os);
} else {
var ci = info((Class<?>)x);
if (ci.isAssignableTo(ObjectSwap.class))
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 b8d141a09d..6d4f046eea 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
@@ -1233,7 +1233,11 @@ public class BeanSession extends ContextSession
implements ConverterSession {
}
var ctxConverter = ctx.getConverter();
- if (ctxConverter != null &&
ctxConverter.hasCustomConversion(from.inner(), tc))
+
+ if (to.isCharSequence() &&
(from.isDateOrCalendarOrTemporal() || from.isDuration()))
+ return (T) Iso8601Utils.format(value, from,
getTimeZone());
+
+ if (ctxConverter.hasCustomConversion(from.inner(), tc))
return ctxConverter.to(value, outer, this, tc);
if (to.isCharSequence() &&
(from.isDateOrCalendarOrTemporal() || from.isDuration()))