Payload { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Payload other = (Payload) o; return this.compressionInfo.equals(other.compressionInfo) && this.data.equals(other.data); } private  Payload(ConfigPayload payload); private  Payload(Utf8Array payload, CompressionInfo compressionInfo); static Payload from(ConfigPayload payload); static Payload from(String payload); static Payload from(String payload, CompressionInfo compressionInfo); static Payload from(Utf8Array payload); static Payload from(Utf8Array payload, CompressionInfo compressionInfo); Utf8Array getData(); Payload withCompression(CompressionType requestedCompression); CompressionInfo getCompressionInfo(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() { final String foo1 = "foo 1"; final String foo2 = "foo 2"; Payload a = Payload.from(foo1); Payload b = Payload.from(foo1); Payload c = Payload.from(foo2); Slime slime = new Slime(); slime.setString(foo1); Payload d = Payload.from(new ConfigPayload(slime)); slime.setString(foo1); Payload e = Payload.from(new ConfigPayload(slime)); slime.setString("foo 2"); Payload f = Payload.from(new ConfigPayload(slime)); Payload g = null; Payload h = null; Payload i = null; Payload j = null; g = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed()); h = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed()); LZ4PayloadCompressor compressor = new LZ4PayloadCompressor(); CompressionInfo info = CompressionInfo.create(CompressionType.LZ4, foo2.length()); Utf8Array compressed = new Utf8Array(compressor.compress(foo2.getBytes())); i = Payload.from(compressed, info); j = Payload.from(compressed, info); new EqualsTester() .addEqualityGroup(a, b, g, h) .addEqualityGroup(c) .addEqualityGroup(d, e) .addEqualityGroup(f) .addEqualityGroup(i, j). testEquals(); }