|
47 | 47 | import java.time.ZoneOffset; |
48 | 48 | import java.util.Arrays; |
49 | 49 | import java.util.HashMap; |
50 | | -import java.util.LinkedHashSet; |
| 50 | +import java.util.HashSet; |
51 | 51 | import java.util.Map; |
52 | 52 | import java.util.Set; |
53 | 53 |
|
@@ -83,27 +83,24 @@ public class PojoConverterUtils<T> { |
83 | 83 | private static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = new HashMap<>(); |
84 | 84 |
|
85 | 85 | static { |
86 | | - SUPPORTED_TYPES.put(DataTypeRoot.BOOLEAN, orderedSet(Boolean.class, boolean.class)); |
87 | | - SUPPORTED_TYPES.put(DataTypeRoot.TINYINT, orderedSet(Byte.class, byte.class)); |
88 | | - SUPPORTED_TYPES.put(DataTypeRoot.SMALLINT, orderedSet(Short.class, short.class)); |
89 | | - SUPPORTED_TYPES.put(DataTypeRoot.INTEGER, orderedSet(Integer.class, int.class)); |
90 | | - SUPPORTED_TYPES.put(DataTypeRoot.BIGINT, orderedSet(Long.class, long.class)); |
91 | | - SUPPORTED_TYPES.put(DataTypeRoot.FLOAT, orderedSet(Float.class, float.class)); |
92 | | - SUPPORTED_TYPES.put(DataTypeRoot.DOUBLE, orderedSet(Double.class, double.class)); |
93 | | - SUPPORTED_TYPES.put( |
94 | | - DataTypeRoot.CHAR, orderedSet(String.class, Character.class, char.class)); |
95 | | - SUPPORTED_TYPES.put( |
96 | | - DataTypeRoot.STRING, orderedSet(String.class, Character.class, char.class)); |
97 | | - SUPPORTED_TYPES.put(DataTypeRoot.BINARY, orderedSet(byte[].class)); |
98 | | - SUPPORTED_TYPES.put(DataTypeRoot.BYTES, orderedSet(byte[].class)); |
99 | | - SUPPORTED_TYPES.put(DataTypeRoot.DECIMAL, orderedSet(BigDecimal.class)); |
100 | | - SUPPORTED_TYPES.put(DataTypeRoot.DATE, orderedSet(LocalDate.class)); |
101 | | - SUPPORTED_TYPES.put(DataTypeRoot.TIME_WITHOUT_TIME_ZONE, orderedSet(LocalTime.class)); |
102 | | - SUPPORTED_TYPES.put( |
103 | | - DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE, orderedSet(LocalDateTime.class)); |
| 86 | + SUPPORTED_TYPES.put(DataTypeRoot.BOOLEAN, setOf(Boolean.class, boolean.class)); |
| 87 | + SUPPORTED_TYPES.put(DataTypeRoot.TINYINT, setOf(Byte.class, byte.class)); |
| 88 | + SUPPORTED_TYPES.put(DataTypeRoot.SMALLINT, setOf(Short.class, short.class)); |
| 89 | + SUPPORTED_TYPES.put(DataTypeRoot.INTEGER, setOf(Integer.class, int.class)); |
| 90 | + SUPPORTED_TYPES.put(DataTypeRoot.BIGINT, setOf(Long.class, long.class)); |
| 91 | + SUPPORTED_TYPES.put(DataTypeRoot.FLOAT, setOf(Float.class, float.class)); |
| 92 | + SUPPORTED_TYPES.put(DataTypeRoot.DOUBLE, setOf(Double.class, double.class)); |
| 93 | + SUPPORTED_TYPES.put(DataTypeRoot.CHAR, setOf(String.class, Character.class, char.class)); |
| 94 | + SUPPORTED_TYPES.put(DataTypeRoot.STRING, setOf(String.class, Character.class, char.class)); |
| 95 | + SUPPORTED_TYPES.put(DataTypeRoot.BINARY, setOf(byte[].class)); |
| 96 | + SUPPORTED_TYPES.put(DataTypeRoot.BYTES, setOf(byte[].class)); |
| 97 | + SUPPORTED_TYPES.put(DataTypeRoot.DECIMAL, setOf(BigDecimal.class)); |
| 98 | + SUPPORTED_TYPES.put(DataTypeRoot.DATE, setOf(LocalDate.class)); |
| 99 | + SUPPORTED_TYPES.put(DataTypeRoot.TIME_WITHOUT_TIME_ZONE, setOf(LocalTime.class)); |
| 100 | + SUPPORTED_TYPES.put(DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE, setOf(LocalDateTime.class)); |
104 | 101 | SUPPORTED_TYPES.put( |
105 | 102 | DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE, |
106 | | - orderedSet(Instant.class, OffsetDateTime.class)); |
| 103 | + setOf(Instant.class, OffsetDateTime.class)); |
107 | 104 |
|
108 | 105 | // TODO: Add more types when https://github.com/apache/fluss/issues/816 is merged |
109 | 106 | } |
@@ -558,17 +555,12 @@ private static int getPrecision(DataType dataType) { |
558 | 555 | } |
559 | 556 |
|
560 | 557 | /** |
561 | | - * Utility method to create an ordered {@link LinkedHashSet} containing the specified Java type |
562 | | - * classes. |
563 | | - * |
564 | | - * <p>The returned set maintains the insertion order of the provided classes. |
| 558 | + * Utility method to create a Set containing the specified Java type classes. |
565 | 559 | * |
566 | 560 | * @param javaTypes The Java type classes to include in the set. May be one or more classes. |
567 | | - * @return A new {@link LinkedHashSet} containing the given classes, preserving their order. |
| 561 | + * @return A new Set containing the given classes. |
568 | 562 | */ |
569 | | - private static LinkedHashSet<Class<?>> orderedSet(Class<?>... javaTypes) { |
570 | | - LinkedHashSet<Class<?>> linkedHashSet = new LinkedHashSet<>(); |
571 | | - linkedHashSet.addAll(Arrays.asList(javaTypes)); |
572 | | - return linkedHashSet; |
| 563 | + private static Set<Class<?>> setOf(Class<?>... javaTypes) { |
| 564 | + return new HashSet<>(Arrays.asList(javaTypes)); |
573 | 565 | } |
574 | 566 | } |
0 commit comments