|
28 | 28 | import java.util.ArrayList;
|
29 | 29 | import java.util.Collection;
|
30 | 30 | import java.util.Date;
|
31 |
| -import java.util.EnumSet; |
| 31 | +import java.util.HashMap; |
| 32 | +import java.util.Map; |
32 | 33 | import java.util.Set;
|
33 | 34 | import java.util.UUID;
|
34 | 35 |
|
|
74 | 75 | */
|
75 | 76 | class JpaPredicateBuilder {
|
76 | 77 |
|
| 78 | + public static final Map<Class<?>, Class<?>> WRAPPERS_TO_PRIMITIVES = new HashMap<Class<?>, Class<?>>(); |
| 79 | + public static final Map<Class<?>, Class<?>> PRIMITIVES_TO_WRAPPERS = new HashMap<Class<?>, Class<?>>(); |
| 80 | + |
| 81 | + static { |
| 82 | + PRIMITIVES_TO_WRAPPERS.put(boolean.class, Boolean.class); |
| 83 | + PRIMITIVES_TO_WRAPPERS.put(byte.class, Byte.class); |
| 84 | + PRIMITIVES_TO_WRAPPERS.put(char.class, Character.class); |
| 85 | + PRIMITIVES_TO_WRAPPERS.put(double.class, Double.class); |
| 86 | + PRIMITIVES_TO_WRAPPERS.put(float.class, Float.class); |
| 87 | + PRIMITIVES_TO_WRAPPERS.put(int.class, Integer.class); |
| 88 | + PRIMITIVES_TO_WRAPPERS.put(long.class, Long.class); |
| 89 | + PRIMITIVES_TO_WRAPPERS.put(short.class, Short.class); |
| 90 | + PRIMITIVES_TO_WRAPPERS.put(void.class, Void.class); |
| 91 | + |
| 92 | + WRAPPERS_TO_PRIMITIVES.put(Boolean.class, boolean.class); |
| 93 | + WRAPPERS_TO_PRIMITIVES.put(Byte.class, byte.class); |
| 94 | + WRAPPERS_TO_PRIMITIVES.put(Character.class, char.class); |
| 95 | + WRAPPERS_TO_PRIMITIVES.put(Double.class, double.class); |
| 96 | + WRAPPERS_TO_PRIMITIVES.put(Float.class, float.class); |
| 97 | + WRAPPERS_TO_PRIMITIVES.put(Integer.class, int.class); |
| 98 | + WRAPPERS_TO_PRIMITIVES.put(Long.class, long.class); |
| 99 | + WRAPPERS_TO_PRIMITIVES.put(Short.class, short.class); |
| 100 | + WRAPPERS_TO_PRIMITIVES.put(Void.class, void.class); |
| 101 | + } |
| 102 | + |
77 | 103 | private final CriteriaBuilder cb;
|
78 | 104 |
|
79 |
| - private final EnumSet<Logical> globalOptions; |
80 |
| - |
81 | 105 | /**
|
82 |
| - * Field name can be prepended with (comma separated list of local options) |
83 |
| - * if field is prepended with (), even without options, any global options |
84 |
| - * avoided and defaults are used.Defaults: for numbers and booleas - |
85 |
| - * equality; for strings case insensitive beginning matches; for dates |
86 |
| - * greater or equal; |
87 |
| - * |
| 106 | + * JpaPredicateBuilder constructor |
| 107 | + * |
88 | 108 | * @param cb
|
89 |
| - * @param globalOptions |
90 | 109 | */
|
91 |
| - public JpaPredicateBuilder(CriteriaBuilder cb, EnumSet<Logical> globalOptions) { |
| 110 | + public JpaPredicateBuilder(CriteriaBuilder cb) { |
92 | 111 | this.cb = cb;
|
93 |
| - this.globalOptions = globalOptions; |
94 | 112 | }
|
95 | 113 |
|
96 | 114 | protected Predicate addOrNull(Path<?> root, Predicate p) {
|
@@ -656,7 +674,7 @@ private Predicate getTypedPredicate(From<?,?> from, Path<?> field, PredicateFilt
|
656 | 674 | PredicateFilter predicateFilter = new PredicateFilter(filter.getField(), value, criterias);
|
657 | 675 |
|
658 | 676 | if (type.isPrimitive())
|
659 |
| - type = JpaQueryBuilder.PRIMITIVES_TO_WRAPPERS.get(type); |
| 677 | + type = PRIMITIVES_TO_WRAPPERS.get(type); |
660 | 678 | if (type.equals(String.class)) {
|
661 | 679 | return getStringPredicate((Path<String>)field, filter);
|
662 | 680 | }
|
|
0 commit comments