@Override public Void visit(BsonBinary value, ByteBuf arg) { NonIoByteSource byteSource = value.getByteSource(); UnsignedInteger unsignedSize; unsignedSize = UnsignedInteger.valueOf(byteSource.size()); arg.writeInt(unsignedSize.intValue()).writeByte(value.getNumericSubType()); try (OutputStream os = new ByteBufOutputStream(arg)) { value.getByteSource().copyTo(os); } catch (IOException ex) { throw new AssertionError("Unexpected IOException", ex); } return null; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof BsonBinary)) { return false; } BsonBinary other = (BsonBinary) obj; if (this.getSubtype() != other.getSubtype()) { return false; } return this.getByteSource().contentEquals(other.getByteSource()); }
subtype, value.getNumericSubType(), value.getByteSource().getDelegate());
if (this.getByteSource().getDelegate() == other.getByteSource().getDelegate()) { return 0; InputStream otherBis = other.getByteSource().openBufferedStream()) { int myByte = myBis.read(); int otherByte = otherBis.read();
com.torodb.mongowp.bson.BsonBinary casted = (com.torodb.mongowp.bson.BsonBinary) value; return new BsonBinary(casted.getNumericSubType(), casted.getByteSource().read());