|
22 | 22 | public class PainlessCast { |
23 | 23 |
|
24 | 24 | /** Create a standard cast with no boxing/unboxing. */ |
25 | | - public static PainlessCast standard(Class<?> from, Class<?> to, boolean explicit) { |
26 | | - return new PainlessCast(from, to, explicit, null, null, null, null); |
| 25 | + public static PainlessCast originalTypetoTargetType(Class<?> originalType, Class<?> targetType, boolean explicitCast) { |
| 26 | + return new PainlessCast(originalType, targetType, explicitCast, null, null, null, null); |
27 | 27 | } |
28 | 28 |
|
29 | | - /** Create a cast where the from type will be unboxed, and then the cast will be performed. */ |
30 | | - public static PainlessCast unboxFrom(Class<?> from, Class<?> to, boolean explicit, Class<?> unboxFrom) { |
31 | | - return new PainlessCast(from, to, explicit, unboxFrom, null, null, null); |
| 29 | + /** Create a cast where the original type will be unboxed, and then the cast will be performed. */ |
| 30 | + public static PainlessCast unboxOriginalType( |
| 31 | + Class<?> originalType, Class<?> targetType, boolean explicitCast, Class<?> unboxOriginalType) { |
| 32 | + |
| 33 | + return new PainlessCast(originalType, targetType, explicitCast, unboxOriginalType, null, null, null); |
32 | 34 | } |
33 | 35 |
|
34 | | - /** Create a cast where the to type will be unboxed, and then the cast will be performed. */ |
35 | | - public static PainlessCast unboxTo(Class<?> from, Class<?> to, boolean explicit, Class<?> unboxTo) { |
36 | | - return new PainlessCast(from, to, explicit, null, unboxTo, null, null); |
| 36 | + /** Create a cast where the target type will be unboxed, and then the cast will be performed. */ |
| 37 | + public static PainlessCast unboxTargetType( |
| 38 | + Class<?> originalType, Class<?> targetType, boolean explicitCast, Class<?> unboxTargetType) { |
| 39 | + |
| 40 | + return new PainlessCast(originalType, targetType, explicitCast, null, unboxTargetType, null, null); |
37 | 41 | } |
38 | 42 |
|
39 | | - /** Create a cast where the from type will be boxed, and then the cast will be performed. */ |
40 | | - public static PainlessCast boxFrom(Class<?> from, Class<?> to, boolean explicit, Class<?> boxFrom) { |
41 | | - return new PainlessCast(from, to, explicit, null, null, boxFrom, null); |
| 43 | + /** Create a cast where the original type will be boxed, and then the cast will be performed. */ |
| 44 | + public static PainlessCast boxOriginalType( |
| 45 | + Class<?> originalType, Class<?> targetType, boolean explicitCast, Class<?> boxOriginalType) { |
| 46 | + |
| 47 | + return new PainlessCast(originalType, targetType, explicitCast, null, null, boxOriginalType, null); |
42 | 48 | } |
43 | 49 |
|
44 | | - /** Create a cast where the to type will be boxed, and then the cast will be performed. */ |
45 | | - public static PainlessCast boxTo(Class<?> from, Class<?> to, boolean explicit, Class<?> boxTo) { |
46 | | - return new PainlessCast(from, to, explicit, null, null, null, boxTo); |
| 50 | + /** Create a cast where the target type will be boxed, and then the cast will be performed. */ |
| 51 | + public static PainlessCast boxTargetType( |
| 52 | + Class<?> originalType, Class<?> targetType, boolean explicitCast, Class<?> boxTargetType) { |
| 53 | + |
| 54 | + return new PainlessCast(originalType, targetType, explicitCast, null, null, null, boxTargetType); |
47 | 55 | } |
48 | 56 |
|
49 | | - public final Class<?> from; |
50 | | - public final Class<?> to; |
51 | | - public final boolean explicit; |
52 | | - public final Class<?> unboxFrom; |
53 | | - public final Class<?> unboxTo; |
54 | | - public final Class<?> boxFrom; |
55 | | - public final Class<?> boxTo; |
| 57 | + public final Class<?> originalType; |
| 58 | + public final Class<?> targetType; |
| 59 | + public final boolean explicitCast; |
| 60 | + public final Class<?> unboxOriginalType; |
| 61 | + public final Class<?> unboxTargetType; |
| 62 | + public final Class<?> boxOriginalType; |
| 63 | + public final Class<?> boxTargetType; |
| 64 | + |
| 65 | + private PainlessCast(Class<?> originalType, Class<?> targetType, boolean explicitCast, |
| 66 | + Class<?> unboxOriginalType, Class<?> unboxTargetType, Class<?> boxOriginalType, Class<?> boxTargetType) { |
56 | 67 |
|
57 | | - private PainlessCast(Class<?> from, Class<?> to, boolean explicit, |
58 | | - Class<?> unboxFrom, Class<?> unboxTo, Class<?> boxFrom, Class<?> boxTo) { |
59 | | - this.from = from; |
60 | | - this.to = to; |
61 | | - this.explicit = explicit; |
62 | | - this.unboxFrom = unboxFrom; |
63 | | - this.unboxTo = unboxTo; |
64 | | - this.boxFrom = boxFrom; |
65 | | - this.boxTo = boxTo; |
| 68 | + this.originalType = originalType; |
| 69 | + this.targetType = targetType; |
| 70 | + this.explicitCast = explicitCast; |
| 71 | + this.unboxOriginalType = unboxOriginalType; |
| 72 | + this.unboxTargetType = unboxTargetType; |
| 73 | + this.boxOriginalType = boxOriginalType; |
| 74 | + this.boxTargetType = boxTargetType; |
66 | 75 | } |
67 | 76 | } |
0 commit comments