SortOrder implements Comparable<SortOrder> { public static SortOrder of(int sortOrder) { Preconditions.checkArgument(sortOrder >= 0, "'sortOrder' must be positive"); return new SortOrder(sortOrder); } private  SortOrder(int sortOrder); static SortOrder getSortOrder(Optional<Role> role); static SortOrder of(int sortOrder); @JsonValue int getSortOrder(); @Override int compareTo(SortOrder o); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void sortOrderShouldNotBeNegative() { assertThatThrownBy(() -> SortOrder.of(-1)).isInstanceOf(IllegalArgumentException.class); }
@Test public void sortOrderShouldBeComparable() { TreeSet<SortOrder> sortedSet = new TreeSet<>(); SortOrder sixtySix = SortOrder.of(66); SortOrder four = SortOrder.of(4); SortOrder five = SortOrder.of(5); sortedSet.add(sixtySix); sortedSet.add(four); sortedSet.add(five); assertThat(sortedSet).containsExactly(four, five, sixtySix); }