@Test public void mergingListsWithDifferentLinksShouldResultInMergedLinks() throws Exception { final List<ResourceLink> first = asList(STOREFRONT_LINK, ABOUTPAGE_LINK); final List<DirectLink> second = asList(SHOPPAGES_LINK, FOO_LINK); final List<? extends ResourceLink> resourceLinks = mergeResources( first, second ); assertEquals(resourceLinks, asList(STOREFRONT_LINK, ABOUTPAGE_LINK, SHOPPAGES_LINK, FOO_LINK)); assertEquals(first.size(), 2); assertEquals(second.size(), 2); }
public static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks, final List<? extends ResourceLink> other) { if (other.isEmpty()) { return resourceLinks; } else { List<? extends ResourceLink> result = resourceLinks; for (final ResourceLink resourceLink : other) { result = mergeResources(result, resourceLink); } return result; } }
ResourceLinkHelper { public static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks, final List<? extends ResourceLink> other) { if (other.isEmpty()) { return resourceLinks; } else { List<? extends ResourceLink> result = resourceLinks; for (final ResourceLink resourceLink : other) { result = mergeResources(result, resourceLink); } return result; } } }
ResourceLinkHelper { public static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks, final List<? extends ResourceLink> other) { if (other.isEmpty()) { return resourceLinks; } else { List<? extends ResourceLink> result = resourceLinks; for (final ResourceLink resourceLink : other) { result = mergeResources(result, resourceLink); } return result; } } private  ResourceLinkHelper(); }
ResourceLinkHelper { public static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks, final List<? extends ResourceLink> other) { if (other.isEmpty()) { return resourceLinks; } else { List<? extends ResourceLink> result = resourceLinks; for (final ResourceLink resourceLink : other) { result = mergeResources(result, resourceLink); } return result; } } private  ResourceLinkHelper(); static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks,
                                                    final List<? extends ResourceLink> other); static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks,
                                                    final ResourceLink other); }
ResourceLinkHelper { public static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks, final List<? extends ResourceLink> other) { if (other.isEmpty()) { return resourceLinks; } else { List<? extends ResourceLink> result = resourceLinks; for (final ResourceLink resourceLink : other) { result = mergeResources(result, resourceLink); } return result; } } private  ResourceLinkHelper(); static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks,
                                                    final List<? extends ResourceLink> other); static List<? extends ResourceLink> mergeResources(final List<? extends ResourceLink> resourceLinks,
                                                    final ResourceLink other);  }