DomainUtil { public static <PK extends Serializable> List<PK> getIdsFromDomainObjects(Collection<? extends DomainObject<PK, ?>> domainObjects) { List<PK> pks = Lists.newArrayList(); if (domainObjects == null) { return pks; } for (DomainObject<PK, ?> domainObject : domainObjects) { pks.add(domainObject.getPK()); } return pks; } private  DomainUtil(); static List<PK> getIdsFromDomainObjects(Collection<? extends DomainObject<PK, ?>> domainObjects);  }
@Test public void testGetPKsFromDomainObjects() { List<Project> projectIds = new ArrayList<>(); projectIds.add(new Project(1)); projectIds.add(new Project(2)); projectIds.add(new Project(3)); projectIds.add(new Project(4)); List<Integer> ints = DomainUtil.getIdsFromDomainObjects(projectIds); assertEquals(4, ints.size()); }