| 1 21 package com.db4o.db4ounit.jre11.staging; 22 23 import db4ounit.*; 24 import db4ounit.extensions.*; 25 26 27 public class PrimitiveWrapperArrayTestCase extends AbstractDb4oTestCase { 28 29 public static void main(String [] args) { 30 new PrimitiveWrapperArrayTestCase().runSolo(); 31 } 32 33 protected void store() throws Exception { 34 store(Item.testInstance()); 35 } 36 37 public void test(){ 38 Item item = (Item) retrieveOnlyInstance(Item.class); 39 Assert.areEqual(Item.testInstance(), item); 40 } 41 42 public static class Item{ 43 44 public Boolean [] _booleans; 45 46 public Item(){ 47 48 } 49 50 public Item(Boolean [] booleans){ 51 _booleans = booleans; 52 } 53 54 public static Item testInstance(){ 55 Boolean [] booleans = new Boolean []{new Boolean (true), new Boolean (false), null }; 56 return new Item(booleans); 57 } 58 59 public boolean equals(Object obj) { 60 if(! (obj instanceof Item)){ 61 return false; 62 } 63 Item other = (Item)obj; 64 return areEqual(_booleans, other._booleans); 65 } 66 67 public static boolean areEqual(Boolean [] cmp, Boolean [] with){ 68 if(cmp == null){ 69 return with == null; 70 } 71 if(with == null){ 72 return false; 73 } 74 if(cmp.length != with.length){ 75 return false; 76 } 77 for (int i = 0; i < cmp.length; i++) { 78 if(! areEqual(cmp[i], with[i])){ 79 return false; 80 } 81 } 82 return true; 83 } 84 85 public static boolean areEqual(Boolean cmp, Boolean with){ 86 if(cmp == null){ 87 return with == null; 88 } 89 return cmp.equals(with); 90 } 91 92 public String toString() { 93 String res = "Item: "; 94 if(_booleans == null){ 95 return res + "[null]"; 96 } 97 if(_booleans.length == 0){ 98 return res + "{ }"; 99 } 100 res += "{ " + _booleans[0]; 101 for (int i = 1; i < _booleans.length; i++) { 102 res += ", " + _booleans[i]; 103 } 104 res += " }"; 105 return res; 106 } 107 108 } 109 110 } 111 | Popular Tags |