1 29 package com.eaio.nativecall; 30 31 38 public class Holder { 39 40 45 private Object o; 46 47 54 public Holder(Object o) { 55 if (o instanceof Holder) { 56 throw new ClassCastException (); 57 } 58 else if (o == null) { 59 o = new Integer (0); 60 } 61 this.o = o; 62 } 63 64 69 public final Object get() { 70 return o; 71 } 72 73 80 public int hashCode() { 81 return getClass().getName().hashCode() ^ (o == null ? 0 : o.hashCode()); 82 } 83 84 91 public boolean equals(Object obj) { 92 if (this == obj) { 93 return true; 94 } 95 if (!(obj instanceof Holder)) { 96 return false; 97 } 98 Holder h = (Holder) obj; 99 return o == null ? h.o == null : o.equals(h.o); 100 } 101 102 109 public final String toString() { 110 return toStringBuffer(null).toString(); 111 } 112 113 120 public StringBuffer toStringBuffer(StringBuffer in) { 121 if (in == null) { 122 in = new StringBuffer (32); 123 } 124 else { 125 in.ensureCapacity(in.length() + 32); 126 } 127 in.append("{ Holder: o = "); 128 in.append(o); 129 in.append(" }"); 130 return in; 131 } 132 133 } 134 | Popular Tags |