| 7 | import java.util.Comparator; |
| 8 | |
| 9 | public interface TestOrder { |
| 10 | @Retention(RetentionPolicy.RUNTIME) |
| 11 | @Target(ElementType.METHOD) |
| 12 | @interface Order { |
| 13 | int value(); |
| 14 | } |
| 15 | |
| 16 | static Comparator<TestOrder.Order> comparator() { |
| 17 | return (or1, or2) -> { |
| 18 | if (or1 != null && or2 != null) { |
| 19 | return or1.value() - or2.value(); |
| 20 | } else if (or1 != null) { |
| 21 | return -1; |
| 22 | } else if (or2 != null) { |
| 23 | return 1; |
| 24 | } |
| 25 | return 0; |
| 26 | }; |
| 27 | } |
| 28 | } |