1 21 package com.db4o.test.java; 22 23 import java.lang.reflect.*; 24 25 import com.db4o.inside.marshall.*; 26 import com.db4o.test.*; 27 28 29 public class PrimitiveWrappers { 30 31 public Boolean boolNull; 32 public Boolean boolMin; 33 public Boolean boolMax; 34 35 public Byte bNull; 36 public Byte bMin; 37 public Byte bMax; 38 39 public Character cNull; 40 public Character cMin; 41 public Character cMax; 42 43 public Double dNull; 44 public Double dMin; 45 public Double dMax; 46 47 public Float fNull; 48 public Float fMin; 49 public Float fMax; 50 51 public Integer iNull; 52 public Integer iMin; 53 public Integer iMax; 54 55 public Long lNull; 56 public Long lMin; 57 public Long lMax; 58 59 public Short sNull; 60 public Short sMin; 61 public Short sMax; 62 63 64 public void storeOne(){ 65 66 boolMin = new Boolean (false); 67 boolMax = new Boolean (true); 68 69 bMin = new Byte (Byte.MAX_VALUE); 70 bMax = new Byte (Byte.MAX_VALUE); 71 72 cMin = new Character (Character.MIN_VALUE); 73 cMax = new Character (Character.MAX_VALUE); 74 75 dMin = new Double (Double.MIN_VALUE); 76 dMax = new Double (Double.MAX_VALUE); 77 78 fMin = new Float (Float.MIN_VALUE); 79 fMax = new Float (Float.MAX_VALUE); 80 81 iMin = new Integer (Integer.MIN_VALUE); 82 iMax = new Integer (Integer.MAX_VALUE); 83 84 lMin = new Long (Long.MIN_VALUE); 85 lMax = new Long (Long.MAX_VALUE); 86 87 sMin = new Short (Short.MIN_VALUE); 88 sMax = new Short (Short.MAX_VALUE); 89 90 } 91 92 public void testOne(){ 93 PrimitiveWrappers original = new PrimitiveWrappers(); 94 original.storeOne(); 95 Test.ensure(this.equals(original)); 96 } 97 98 public boolean equals(Object obj) { 99 if(! (obj instanceof PrimitiveWrappers)){ 100 return false; 101 } 102 try { 103 Class clazz = getClass(); 104 Field[] fields = clazz.getDeclaredFields(); 105 for (int i = 0; i < fields.length; i++) { 106 Field field = fields[i]; 107 Object myMember = field.get(this); 108 Object otherMember = field.get(obj); 109 if(myMember == null){ 110 if(otherMember != null){ 111 return false; 112 } 113 }else{ 114 if(! myMember.equals(otherMember)){ 115 return false; 116 } 117 } 118 } 119 } catch (Exception e) { 120 e.printStackTrace(); 121 } 122 return true; 123 } 124 125 } 126 | Popular Tags |