You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/01/07 12:24:34 UTC
[camel] branch master updated: CAMEL-16000: Add type converter for
Map to Collection (set) as previously the slower type converter was able to
do this. The new optimize converters requires more specific converter pairs
to be really fast.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new d734f80 CAMEL-16000: Add type converter for Map to Collection (set) as previously the slower type converter was able to do this. The new optimize converters requires more specific converter pairs to be really fast.
d734f80 is described below
commit d734f80b00bf22095c774d9886e2593ac870c703
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 7 12:16:23 2021 +0100
CAMEL-16000: Add type converter for Map to Collection (set) as previously the slower type converter was able to do this. The new optimize converters requires more specific converter pairs to be really fast.
---
.../camel/converter/CamelBaseBulkConverterLoader.java | 10 +++++++++-
.../org/apache/camel/converter/CollectionConverter.java | 13 +++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/core/camel-base/src/generated/java/org/apache/camel/converter/CamelBaseBulkConverterLoader.java b/core/camel-base/src/generated/java/org/apache/camel/converter/CamelBaseBulkConverterLoader.java
index deab870..f9e385f 100644
--- a/core/camel-base/src/generated/java/org/apache/camel/converter/CamelBaseBulkConverterLoader.java
+++ b/core/camel-base/src/generated/java/org/apache/camel/converter/CamelBaseBulkConverterLoader.java
@@ -26,7 +26,7 @@ public final class CamelBaseBulkConverterLoader implements TypeConverterLoader,
@Override
public int size() {
- return 103;
+ return 104;
}
@Override
@@ -363,6 +363,10 @@ public final class CamelBaseBulkConverterLoader implements TypeConverterLoader,
if (value instanceof java.lang.Iterable) {
return org.apache.camel.converter.CollectionConverter.toArrayList((java.lang.Iterable) value);
}
+ } else if (to == java.util.Collection.class) {
+ if (value instanceof java.util.Map) {
+ return org.apache.camel.converter.CollectionConverter.toCollection((java.util.Map) value);
+ }
} else if (to == java.util.Date.class) {
if (value instanceof java.lang.Long) {
return org.apache.camel.converter.DateTimeConverter.toDate((java.lang.Long) value);
@@ -718,6 +722,10 @@ public final class CamelBaseBulkConverterLoader implements TypeConverterLoader,
if (from == java.lang.Iterable.class) {
return this;
}
+ } else if (to == java.util.Collection.class) {
+ if (from == java.util.Map.class) {
+ return this;
+ }
} else if (to == java.util.Date.class) {
if (from == java.lang.Long.class) {
return this;
diff --git a/core/camel-base/src/main/java/org/apache/camel/converter/CollectionConverter.java b/core/camel-base/src/main/java/org/apache/camel/converter/CollectionConverter.java
index d702bac..1cf25a9 100644
--- a/core/camel-base/src/main/java/org/apache/camel/converter/CollectionConverter.java
+++ b/core/camel-base/src/main/java/org/apache/camel/converter/CollectionConverter.java
@@ -115,18 +115,23 @@ public final class CollectionConverter {
}
@Converter(order = 9)
+ public static <K, V> Collection<Map.Entry<K, V>> toCollection(Map<K, V> map) {
+ return map.entrySet();
+ }
+
+ @Converter(order = 10)
public static Properties toProperties(Map<Object, Object> map) {
Properties answer = new Properties();
answer.putAll(map);
return answer;
}
- @Converter(order = 10)
+ @Converter(order = 11)
public static <K, V> Hashtable<K, V> toHashtable(Map<? extends K, ? extends V> map) {
return new Hashtable<>(map);
}
- @Converter(order = 11)
+ @Converter(order = 12)
public static <K, V> HashMap<K, V> toHashMap(Map<? extends K, ? extends V> map) {
return new HashMap<>(map);
}
@@ -134,7 +139,7 @@ public final class CollectionConverter {
/**
* Converts an {@link Iterable} into a {@link List}
*/
- @Converter(order = 12)
+ @Converter(order = 13)
public static <T> List<T> toList(Iterable<T> iterable) {
if (iterable instanceof List) {
return (List<T>) iterable;
@@ -149,7 +154,7 @@ public final class CollectionConverter {
/**
* Converts an {@link Iterator} into a {@link List}
*/
- @Converter(order = 13)
+ @Converter(order = 14)
public static <T> List<T> toList(Iterator<T> it) {
if (it instanceof List) {
return (List<T>) it;