/** * Compares this <code>MarshalledInstance</code> to another object. Returns true if and only if * the argument refers to an instance of <code>MarshalledInstance</code> that contains exactly * the same serialized form for its contained object as this object does and has the same class * codebase annotations. * * @param obj the object to compare with this <code>MarshalledInstance</code> * @return <code>true</code> if the argument contains an object with an equivalent serialized * form and codebase; otherwise returns <code>false</code> */ public boolean fullyEquals(Object obj) { if (equals(obj)) { MarshalledInstance other = (MarshalledInstance) obj; return Arrays.equals(locBytes, other.locBytes); } return false; }
/** * Compares this <code>MarshalledInstance</code> to another * object. Returns true if and only if the argument refers to an instance * of <code>MarshalledInstance</code> that contains exactly the same * serialized form for its contained object as this object does and * has the same class codebase annotations. * * @param obj the object to compare with this * <code>MarshalledInstance</code> * @return <code>true</code> if the argument contains an object * with an equivalent serialized form and codebase; * otherwise returns <code>false</code> */ public boolean fullyEquals(Object obj) { if (equals(obj)) { MarshalledInstance other = (MarshalledInstance)obj; return Arrays.equals(locBytes, other.locBytes); } return false; }
/** * Compares the specified object with this <code>MarshalledWrapper</code> * for equality. This method returns <code>true</code> if and only if the * specified object is of the same class as this object and its wrapped * <code>MarshalledInstance</code> is equal to the one in this object. * * @param obj object to compare with * @return <code>true</code> if <code>obj</code> is equivalent to * this object; <code>false</code> otherwise */ public boolean equals(Object obj) { return obj == this || (obj != null && obj.getClass() == getClass() && instance.equals(((MarshalledWrapper) obj).instance)); }
/** * Compares the specified object with this <code>MarshalledWrapper</code> for equality. This * method returns <code>true</code> if and only if the specified object is of the same class as * this object and its wrapped <code>MarshalledInstance</code> is equal to the one in this * object. * * @param obj object to compare with * @return <code>true</code> if <code>obj</code> is equivalent to this object; * <code>false</code> otherwise */ public boolean equals(Object obj) { return obj == this || (obj != null && obj.getClass() == getClass() && instance.equals(((MarshalledWrapper) obj).instance)); }
/** * Returns <code>true</code> if the two input objects are the same in * <code>MarshalledInstance</code> form, <code>false</code> otherwise. */ private static boolean equal(Object o1, Object o2) { if (o1 == o2) return true; if (o1 == null || o2 == null) return false; Class c = o1.getClass(); if (c == String.class || c == Integer.class || c == Boolean.class || c == Character.class || c == Long.class || c == Float.class || c == Double.class || c == Byte.class || c == Short.class) return o1.equals(o2); try { return new MarshalledInstance(o1).equals(new MarshalledInstance(o2)); } catch (IOException ex) { throw new IllegalArgumentException("unexpected IOException"); } }