1 | /* |
2 | * Copyright 2007 brunella ltd |
3 | * |
4 | * Licensed under the LGPL Version 3 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * |
7 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
8 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
10 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
11 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
12 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
13 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
14 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
15 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
16 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
17 | * THE POSSIBILITY OF SUCH DAMAGE. |
18 | */ |
19 | package sf.qof.mapping; |
20 | |
21 | import java.util.HashSet; |
22 | import java.util.Set; |
23 | |
24 | public abstract class AbstractNumberMapping extends AbstractBaseMapping implements Mapping, ParameterMapping, |
25 | ResultMapping { |
26 | |
27 | public void accept(Mapper mapper, MappingVisitor visitor) { |
28 | visitor.visit(mapper, this); |
29 | } |
30 | |
31 | public abstract void accept(Mapper mapper, NumberMappingVisitor visitor); |
32 | |
33 | public static class ByteMapping extends AbstractNumberMapping { |
34 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
35 | static { |
36 | types.add(Byte.TYPE); |
37 | types.add(Byte.class); |
38 | } |
39 | |
40 | public static Set<Class<?>> getTypes() { |
41 | return types; |
42 | } |
43 | |
44 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
45 | visitor.visit(mapper, this); |
46 | } |
47 | } |
48 | |
49 | public static class ShortMapping extends AbstractNumberMapping { |
50 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
51 | static { |
52 | types.add(Short.TYPE); |
53 | types.add(Short.class); |
54 | } |
55 | |
56 | public static Set<Class<?>> getTypes() { |
57 | return types; |
58 | } |
59 | |
60 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
61 | visitor.visit(mapper, this); |
62 | } |
63 | } |
64 | |
65 | public static class IntegerMapping extends AbstractNumberMapping { |
66 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
67 | static { |
68 | types.add(Integer.TYPE); |
69 | types.add(Integer.class); |
70 | } |
71 | |
72 | public static Set<Class<?>> getTypes() { |
73 | return types; |
74 | } |
75 | |
76 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
77 | visitor.visit(mapper, this); |
78 | } |
79 | } |
80 | |
81 | public static class LongMapping extends AbstractNumberMapping { |
82 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
83 | static { |
84 | types.add(Long.TYPE); |
85 | types.add(Long.class); |
86 | } |
87 | |
88 | public static Set<Class<?>> getTypes() { |
89 | return types; |
90 | } |
91 | |
92 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
93 | visitor.visit(mapper, this); |
94 | } |
95 | } |
96 | |
97 | public static class FloatMapping extends AbstractNumberMapping { |
98 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
99 | static { |
100 | types.add(Float.TYPE); |
101 | types.add(Float.class); |
102 | } |
103 | |
104 | public static Set<Class<?>> getTypes() { |
105 | return types; |
106 | } |
107 | |
108 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
109 | visitor.visit(mapper, this); |
110 | } |
111 | } |
112 | |
113 | public static class DoubleMapping extends AbstractNumberMapping { |
114 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
115 | static { |
116 | types.add(Double.TYPE); |
117 | types.add(Double.class); |
118 | } |
119 | |
120 | public static Set<Class<?>> getTypes() { |
121 | return types; |
122 | } |
123 | |
124 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
125 | visitor.visit(mapper, this); |
126 | } |
127 | } |
128 | |
129 | public static class BooleanMapping extends AbstractNumberMapping { |
130 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
131 | static { |
132 | types.add(Boolean.TYPE); |
133 | types.add(Boolean.class); |
134 | } |
135 | |
136 | public static Set<Class<?>> getTypes() { |
137 | return types; |
138 | } |
139 | |
140 | public void accept(Mapper mapper, NumberMappingVisitor visitor) { |
141 | visitor.visit(mapper, this); |
142 | } |
143 | } |
144 | } |