@Test public void testCreateEndpointGroupIdOrdering() throws Exception { final Ordering<EndpointGroupId> endpointGroupIdOrdering = RendererPolicyUtil.createEndpointGroupIdOrdering(); final String epg1 = "epg1"; final ArrayList<EndpointGroupId> list = Lists.newArrayList( new EndpointGroupId("epg3"), new EndpointGroupId(epg1), new EndpointGroupId("epg2")); Collections.sort(list, endpointGroupIdOrdering); Assert.assertEquals(epg1, list.get(0).getValue()); Collections.sort(list, endpointGroupIdOrdering.reversed()); Assert.assertEquals(epg1, list.get(2).getValue()); }
public static Ordering<EndpointGroupId> createEndpointGroupIdOrdering() { return Ordering.natural().onResultOf(new Function<EndpointGroupId, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final EndpointGroupId input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); }
RendererPolicyUtil { public static Ordering<EndpointGroupId> createEndpointGroupIdOrdering() { return Ordering.natural().onResultOf(new Function<EndpointGroupId, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final EndpointGroupId input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } }
RendererPolicyUtil { public static Ordering<EndpointGroupId> createEndpointGroupIdOrdering() { return Ordering.natural().onResultOf(new Function<EndpointGroupId, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final EndpointGroupId input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } }); } private  RendererPolicyUtil(); }
RendererPolicyUtil { public static Ordering<EndpointGroupId> createEndpointGroupIdOrdering() { return Ordering.natural().onResultOf(new Function<EndpointGroupId, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final EndpointGroupId 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<EndpointGroupId> createEndpointGroupIdOrdering() { return Ordering.natural().onResultOf(new Function<EndpointGroupId, Comparable>() { @Nullable @Override public Comparable apply(@Nullable final EndpointGroupId 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();  }