001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.harmony.beans.tests.support.mock;
019:
020: import java.lang.reflect.Field;
021: import java.util.Collection;
022:
023: public class MockBean4CodecPrimitives {
024:
025: boolean bool = true;
026:
027: byte b = 1;
028:
029: char c = 'a';
030:
031: double d = 3.14;
032:
033: float f = 3.14F;
034:
035: int i = 4;
036:
037: long l = 8;
038:
039: short s = 2;
040:
041: Boolean boolobj = Boolean.FALSE;
042:
043: Byte bobj = new Byte((byte) 11);
044:
045: Character cobj = new Character('A');
046:
047: Double dobj = new Double(6.28);
048:
049: Float fobj = new Float(6.28F);
050:
051: Integer iobj = new Integer(44);
052:
053: Long lobj = new Long(88);
054:
055: Short sobj = new Short((short) 22);
056:
057: Object nill = "start with not null";
058:
059: Class<?> clazz = Collection.class;
060:
061: int zarr[] = { 1, 2, 3, 4 };
062:
063: String zarrarr[][] = { { "1", "2" }, { "3", "4", "5" } };
064:
065: public MockBean4CodecPrimitives() {
066: super ();
067: }
068:
069: @Override
070: public boolean equals(Object obj) {
071: if (obj == null || !getClass().equals(obj.getClass())) {
072: return false;
073: }
074: try {
075: Field fields[] = getClass().getDeclaredFields();
076: for (Field element : fields) {
077: Object mine = element.get(this );
078: Object other = element.get(obj);
079: if (mine == null ? other != null : !mine.equals(other)) {
080: return false;
081: }
082: }
083: return true;
084: } catch (Exception e) {
085: throw new RuntimeException("impossible!!");
086: }
087: }
088:
089: @Override
090: public int hashCode() {
091: try {
092: int code = 0;
093: Field fields[] = getClass().getDeclaredFields();
094: for (Field element : fields) {
095: Object mine = element.get(this );
096: if (mine != null) {
097: code += mine.hashCode();
098: }
099: }
100: return code;
101: } catch (Exception e) {
102: throw new RuntimeException("impossible!!");
103: }
104: }
105:
106: /**
107: * @return Returns the b.
108: */
109: public byte getB() {
110: return b;
111: }
112:
113: /**
114: * @param b
115: * The b to set.
116: */
117: public void setB(byte b) {
118: this .b = b;
119: }
120:
121: /**
122: * @return Returns the bobj.
123: */
124: public Byte getBobj() {
125: return bobj;
126: }
127:
128: /**
129: * @param bobj
130: * The bobj to set.
131: */
132: public void setBobj(Byte bobj) {
133: this .bobj = bobj;
134: }
135:
136: /**
137: * @return Returns the bool.
138: */
139: public boolean isBool() {
140: return bool;
141: }
142:
143: /**
144: * @param bool
145: * The bool to set.
146: */
147: public void setBool(boolean bool) {
148: this .bool = bool;
149: }
150:
151: /**
152: * @return Returns the boolobj.
153: */
154: public Boolean getBoolobj() {
155: return boolobj;
156: }
157:
158: /**
159: * @param boolobj
160: * The boolobj to set.
161: */
162: public void setBoolobj(Boolean boolobj) {
163: this .boolobj = boolobj;
164: }
165:
166: /**
167: * @return Returns the c.
168: */
169: public char getC() {
170: return c;
171: }
172:
173: /**
174: * @param c
175: * The c to set.
176: */
177: public void setC(char c) {
178: this .c = c;
179: }
180:
181: /**
182: * @return Returns the cobj.
183: */
184: public Character getCobj() {
185: return cobj;
186: }
187:
188: /**
189: * @param cobj
190: * The cobj to set.
191: */
192: public void setCobj(Character cobj) {
193: this .cobj = cobj;
194: }
195:
196: /**
197: * @return Returns the d.
198: */
199: public double getD() {
200: return d;
201: }
202:
203: /**
204: * @param d
205: * The d to set.
206: */
207: public void setD(double d) {
208: this .d = d;
209: }
210:
211: /**
212: * @return Returns the dobj.
213: */
214: public Double getDobj() {
215: return dobj;
216: }
217:
218: /**
219: * @param dobj
220: * The dobj to set.
221: */
222: public void setDobj(Double dobj) {
223: this .dobj = dobj;
224: }
225:
226: /**
227: * @return Returns the f.
228: */
229: public float getF() {
230: return f;
231: }
232:
233: /**
234: * @param f
235: * The f to set.
236: */
237: public void setF(float f) {
238: this .f = f;
239: }
240:
241: /**
242: * @return Returns the fobj.
243: */
244: public Float getFobj() {
245: return fobj;
246: }
247:
248: /**
249: * @param fobj
250: * The fobj to set.
251: */
252: public void setFobj(Float fobj) {
253: this .fobj = fobj;
254: }
255:
256: /**
257: * @return Returns the i.
258: */
259: public int getI() {
260: return i;
261: }
262:
263: /**
264: * @param i
265: * The i to set.
266: */
267: public void setI(int i) {
268: this .i = i;
269: }
270:
271: /**
272: * @return Returns the iobj.
273: */
274: public Integer getIobj() {
275: return iobj;
276: }
277:
278: /**
279: * @param iobj
280: * The iobj to set.
281: */
282: public void setIobj(Integer iobj) {
283: this .iobj = iobj;
284: }
285:
286: /**
287: * @return Returns the l.
288: */
289: public long getL() {
290: return l;
291: }
292:
293: /**
294: * @param l
295: * The l to set.
296: */
297: public void setL(long l) {
298: this .l = l;
299: }
300:
301: /**
302: * @return Returns the lobj.
303: */
304: public Long getLobj() {
305: return lobj;
306: }
307:
308: /**
309: * @param lobj
310: * The lobj to set.
311: */
312: public void setLobj(Long lobj) {
313: this .lobj = lobj;
314: }
315:
316: /**
317: * @return Returns the nill.
318: */
319: public Object getNill() {
320: return nill;
321: }
322:
323: /**
324: * @param nill
325: * The nill to set.
326: */
327: public void setNill(Object nill) {
328: this .nill = nill;
329: }
330:
331: /**
332: * @return Returns the s.
333: */
334: public short getS() {
335: return s;
336: }
337:
338: /**
339: * @param s
340: * The s to set.
341: */
342: public void setS(short s) {
343: this .s = s;
344: }
345:
346: /**
347: * @return Returns the sobj.
348: */
349: public Short getSobj() {
350: return sobj;
351: }
352:
353: /**
354: * @param sobj
355: * The sobj to set.
356: */
357: public void setSobj(Short sobj) {
358: this .sobj = sobj;
359: }
360:
361: /**
362: * @return Returns the clazz.
363: */
364: public Class<?> getClazz() {
365: return clazz;
366: }
367:
368: /**
369: * @param clazz
370: * The clazz to set.
371: */
372: public void setClazz(Class<?> clazz) {
373: this .clazz = clazz;
374: }
375:
376: /**
377: * @return Returns the zarr.
378: */
379: public int[] getZarr() {
380: return zarr;
381: }
382:
383: /**
384: * @param arr
385: * The zarr to set.
386: */
387: public void setZarr(int[] arr) {
388: this .zarr = arr;
389: }
390:
391: /**
392: * @return Returns the zarrarr.
393: */
394: public String[][] getZarrarr() {
395: return zarrarr;
396: }
397:
398: /**
399: * @param arrarr
400: * The zarrarr to set.
401: */
402: public void setZarrarr(String[][] arrarr) {
403: this.zarrarr = arrarr;
404: }
405: }
|