@Test public void testIsIntersectionEntityRefsToEntities() { Entity e1 = mock(Entity.class); when(e1.getReference()).thenReturn("/ref/e1"); Entity e2 = mock(Entity.class); when(e2.getReference()).thenReturn("/ref/e2"); assertTrue(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] { "/ref/e2" }), Arrays.asList(new Entity[] { e1, e2 }))); assertFalse(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] { "/ref/e2" }), Arrays.asList(new Entity[] {}))); assertFalse(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] {}), Arrays.asList(new Entity[] { e1, e2 }))); assertFalse(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] { "/ref/a1", "/ref/a2" }), Arrays.asList(new Entity[] { e1, e2 }))); assertTrue(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] { "/ref/e1", "/ref/e2", "/ref/e3" }), Arrays.asList(new Entity[] { e1, e2 }))); assertTrue(isIntersectionEntityRefsToEntities( Arrays.asList(new String[] { "/ref/e1", "/ref/e2" }), Arrays.asList(new Entity[] { e1, e2 }))); }
public static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities) { for (Iterator<String> iRefs = entityRefs.iterator(); iRefs.hasNext();) { String findThisEntityRef = iRefs.next(); for (Iterator<Entity> iEntities = entities.iterator(); iEntities.hasNext();) { String thisEntityRef = ((Entity) iEntities.next()).getReference(); if (thisEntityRef.equals(findThisEntityRef)) { return true; } } } return false; }
EntityCollections { public static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities) { for (Iterator<String> iRefs = entityRefs.iterator(); iRefs.hasNext();) { String findThisEntityRef = iRefs.next(); for (Iterator<Entity> iEntities = entities.iterator(); iEntities.hasNext();) { String thisEntityRef = ((Entity) iEntities.next()).getReference(); if (thisEntityRef.equals(findThisEntityRef)) { return true; } } } return false; } }
EntityCollections { public static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities) { for (Iterator<String> iRefs = entityRefs.iterator(); iRefs.hasNext();) { String findThisEntityRef = iRefs.next(); for (Iterator<Entity> iEntities = entities.iterator(); iEntities.hasNext();) { String thisEntityRef = ((Entity) iEntities.next()).getReference(); if (thisEntityRef.equals(findThisEntityRef)) { return true; } } } return false; }  }
EntityCollections { public static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities) { for (Iterator<String> iRefs = entityRefs.iterator(); iRefs.hasNext();) { String findThisEntityRef = iRefs.next(); for (Iterator<Entity> iEntities = entities.iterator(); iEntities.hasNext();) { String thisEntityRef = ((Entity) iEntities.next()).getReference(); if (thisEntityRef.equals(findThisEntityRef)) { return true; } } } return false; }  static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean isContainedEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean isEqualEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean entityCollectionContainsRefString(Collection<Entity> entities, String entityRef); static boolean refCollectionContainsEntity(Collection<String> refs, Entity entity); static void setEntityRefsFromEntities(Collection<String> refs, Collection<Entity> entities); static void computeAddedRemovedEntityRefsFromNewEntitiesOldRefs(Collection<String> addedEntities, Collection<String> removedEntities,
			Collection<Entity> newEntities, Collection<String> oldEntityRefs); }
EntityCollections { public static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities) { for (Iterator<String> iRefs = entityRefs.iterator(); iRefs.hasNext();) { String findThisEntityRef = iRefs.next(); for (Iterator<Entity> iEntities = entities.iterator(); iEntities.hasNext();) { String thisEntityRef = ((Entity) iEntities.next()).getReference(); if (thisEntityRef.equals(findThisEntityRef)) { return true; } } } return false; }  static boolean isIntersectionEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean isContainedEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean isEqualEntityRefsToEntities(Collection<String> entityRefs, Collection<Entity> entities); static boolean entityCollectionContainsRefString(Collection<Entity> entities, String entityRef); static boolean refCollectionContainsEntity(Collection<String> refs, Entity entity); static void setEntityRefsFromEntities(Collection<String> refs, Collection<Entity> entities); static void computeAddedRemovedEntityRefsFromNewEntitiesOldRefs(Collection<String> addedEntities, Collection<String> removedEntities,
			Collection<Entity> newEntities, Collection<String> oldEntityRefs);  }