/** {@inheritDoc} */ @Override public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof BinaryObject)) return false; BinaryIdentityResolver identity = context().identity(typeId()); return identity.equals(this, (BinaryObject)other); }
/** * Perform post-write hash code update if necessary. * * @param clsName Class name. Always null if class is registered. */ public void postWriteHashCode(@Nullable String clsName) { int typeId = clsName == null ? this.typeId : ctx.typeId(clsName); BinaryIdentityResolver identity = ctx.identity(typeId); if (out.hasArray()) { // Heap. byte[] data = out.array(); BinaryObjectImpl obj = new BinaryObjectImpl(ctx, data, start); BinaryPrimitives.writeInt(data, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj)); } else { // Offheap. long ptr = out.rawOffheapPointer(); assert ptr != 0; BinaryObjectOffheapImpl obj = new BinaryObjectOffheapImpl(ctx, ptr, start, out.capacity()); BinaryPrimitives.writeInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj)); } }
/** {@inheritDoc} */ @Override public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof BinaryObject)) return false; BinaryIdentityResolver identity = context().identity(typeId()); return identity.equals(this, (BinaryObject)other); }
/** * Perform post-write hash code update if necessary. * * @param clsName Class name. Always null if class is registered. */ public void postWriteHashCode(@Nullable String clsName) { int typeId = clsName == null ? this.typeId : ctx.typeId(clsName); BinaryIdentityResolver identity = ctx.identity(typeId); if (out.hasArray()) { // Heap. byte[] data = out.array(); BinaryObjectImpl obj = new BinaryObjectImpl(ctx, data, start); BinaryPrimitives.writeInt(data, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj)); } else { // Offheap. long ptr = out.rawOffheapPointer(); assert ptr != 0; BinaryObjectOffheapImpl obj = new BinaryObjectOffheapImpl(ctx, ptr, start, out.capacity()); BinaryPrimitives.writeInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj)); } }