@Test public void should_sort_by_status_order() { List<String> unordered = asList(STATUS_OUT_OF_SERVICE, STATUS_UNKNOWN, STATUS_OFFLINE, STATUS_DOWN, STATUS_UP, STATUS_RESTRICTED); List<String> ordered = unordered.stream().sorted(StatusInfo.severity()).collect(Collectors.toList()); assertThat(ordered).containsExactly(STATUS_DOWN, STATUS_OUT_OF_SERVICE, STATUS_OFFLINE, STATUS_UNKNOWN, STATUS_RESTRICTED, STATUS_UP); }
public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); }
StatusInfo implements Serializable { public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); } }
StatusInfo implements Serializable { public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); } private  StatusInfo(String status, @Nullable Map<String, ?> details); }
StatusInfo implements Serializable { public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); } private  StatusInfo(String status, @Nullable Map<String, ?> details); static StatusInfo valueOf(String statusCode, @Nullable Map<String, ?> details); static StatusInfo valueOf(String statusCode); static StatusInfo ofUnknown(); static StatusInfo ofUp(); static StatusInfo ofDown(); static StatusInfo ofOffline(); static StatusInfo ofUp(@Nullable Map<String, Object> details); static StatusInfo ofDown(@Nullable Map<String, Object> details); static StatusInfo ofOffline(@Nullable Map<String, Object> details); Map<String, Object> getDetails(); @JsonIgnore boolean isUp(); @JsonIgnore boolean isOffline(); @JsonIgnore boolean isDown(); @JsonIgnore boolean isUnknown(); static Comparator<String> severity(); @SuppressWarnings("unchecked") static StatusInfo from(Map<String, ?> body); }
StatusInfo implements Serializable { public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); } private  StatusInfo(String status, @Nullable Map<String, ?> details); static StatusInfo valueOf(String statusCode, @Nullable Map<String, ?> details); static StatusInfo valueOf(String statusCode); static StatusInfo ofUnknown(); static StatusInfo ofUp(); static StatusInfo ofDown(); static StatusInfo ofOffline(); static StatusInfo ofUp(@Nullable Map<String, Object> details); static StatusInfo ofDown(@Nullable Map<String, Object> details); static StatusInfo ofOffline(@Nullable Map<String, Object> details); Map<String, Object> getDetails(); @JsonIgnore boolean isUp(); @JsonIgnore boolean isOffline(); @JsonIgnore boolean isDown(); @JsonIgnore boolean isUnknown(); static Comparator<String> severity(); @SuppressWarnings("unchecked") static StatusInfo from(Map<String, ?> body); static final String STATUS_UNKNOWN; static final String STATUS_OUT_OF_SERVICE; static final String STATUS_UP; static final String STATUS_DOWN; static final String STATUS_OFFLINE; static final String STATUS_RESTRICTED; }