@Test public void testCreateConditionNameOrdering() throws Exception { final Ordering<ConditionName> conditionNameOrdering = RendererPolicyUtil.createConditionNameOrdering(); final String name1 = "name1"; final ArrayList<ConditionName> list = Lists.newArrayList( new ConditionName("name3"), new ConditionName(name1), new ConditionName("name2")); Collections.sort(list, conditionNameOrdering); Assert.assertEquals(name1, list.get(0).getValue()); Collections.sort(list, conditionNameOrdering.reversed()); Assert.assertEquals(name1, list.get(2).getValue()); }
public static Ordering<ConditionName> createConditionNameOrdering() { return Ordering.natural().onResultOf(new Function<ConditionName, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final ConditionName input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); }
RendererPolicyUtil { public static Ordering<ConditionName> createConditionNameOrdering() { return Ordering.natural().onResultOf(new Function<ConditionName, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final ConditionName input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } }
RendererPolicyUtil { public static Ordering<ConditionName> createConditionNameOrdering() { return Ordering.natural().onResultOf(new Function<ConditionName, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final ConditionName input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } private  RendererPolicyUtil(); }
RendererPolicyUtil { public static Ordering<ConditionName> createConditionNameOrdering() { return Ordering.natural().onResultOf(new Function<ConditionName, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final ConditionName input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } private  RendererPolicyUtil(); static AddressEndpointWithLocation lookupEndpoint(final AddressEndpointKey rendererEp, final List<AddressEndpointWithLocation> addressEndpointWithLocation); static Ordering<EndpointGroupId> createEndpointGroupIdOrdering(); static Ordering<ConditionName> createConditionNameOrdering(); }
RendererPolicyUtil { public static Ordering<ConditionName> createConditionNameOrdering() { return Ordering.natural().onResultOf(new Function<ConditionName, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final ConditionName input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } private  RendererPolicyUtil(); static AddressEndpointWithLocation lookupEndpoint(final AddressEndpointKey rendererEp, final List<AddressEndpointWithLocation> addressEndpointWithLocation); static Ordering<EndpointGroupId> createEndpointGroupIdOrdering(); static Ordering<ConditionName> createConditionNameOrdering();  }