File tree 2 files changed +13
-0
lines changed
src/main/java/com/palantir/conjure/java/lib 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ dependencies {
26
26
27
27
implementation ' com.fasterxml.jackson.core:jackson-annotations'
28
28
implementation ' com.fasterxml.jackson.core:jackson-core'
29
+ implementation ' com.google.guava:guava'
29
30
implementation ' com.palantir.safe-logging:safe-logging'
30
31
31
32
testImplementation ' com.palantir.safe-logging:preconditions-assertj'
Original file line number Diff line number Diff line change 24
24
import com .fasterxml .jackson .databind .SerializerProvider ;
25
25
import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
26
26
import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
27
+ import com .google .common .primitives .SignedBytes ;
28
+ import com .google .common .primitives .UnsignedBytes ;
27
29
import java .io .ByteArrayInputStream ;
28
30
import java .io .IOException ;
29
31
import java .io .InputStream ;
30
32
import java .nio .ByteBuffer ;
31
33
import java .util .Arrays ;
34
+ import java .util .Comparator ;
35
+ import org .jetbrains .annotations .NotNull ;
32
36
33
37
/** An immutable {@code byte[]} wrapper. */
34
38
@ JsonSerialize (using = Bytes .Serializer .class )
@@ -85,6 +89,14 @@ public boolean equals(Object obj) {
85
89
return this == obj || (obj instanceof Bytes && Arrays .equals (safe , ((Bytes ) obj ).safe ));
86
90
}
87
91
92
+ public Comparator <Bytes > signed () {
93
+ return (x , y ) -> SignedBytes .lexicographicalComparator ().compare (x .safe , y .safe );
94
+ }
95
+
96
+ public Comparator <Bytes > unsigned () {
97
+ return (x , y ) -> UnsignedBytes .lexicographicalComparator ().compare (x .safe , y .safe );
98
+ }
99
+
88
100
@ Override
89
101
public String toString () {
90
102
return "Bytes{size: " + safe .length + '}' ;
You can’t perform that action at this time.
0 commit comments