private Domain findRootOfVisibleTree(Set<Domain> domains) { final Set<String> names = newHashSet(Iterables.transform(domains, new Function<Domain, String>() { @Override public String apply(Domain domain) { return domain.getName(); } })); for (Domain candidate : domains) { if (candidate.getParentDomainId() == null || !names.contains(candidate.getParentDomainName())) { return candidate; } } throw new NoSuchElementException("No root node found in this tree"); } }
private void checkDomain(Domain domain) { assertNotNull(domain.getId()); if (domain.getLevel() == 0 /* global ROOT */) { assertNull(domain.getParentDomainName()); assertNull(domain.getParentDomainId()); } else { assertNotNull(domain.getParentDomainName()); assertNotNull(domain.getParentDomainId()); } }
private void checkDomain(Domain domain) { assertNotNull(domain.getId()); if (domain.getLevel() == 0 /* global ROOT */) { assertNull(domain.getParentDomainName()); assertNull(domain.getParentDomainId()); } else { assertNotNull(domain.getParentDomainName()); assertNotNull(domain.getParentDomainId()); } }
private Domain findRootOfVisibleTree(Set<Domain> domains) { final Set<String> names = newHashSet(Iterables.transform(domains, new Function<Domain, String>() { @Override public String apply(Domain domain) { return domain.getName(); } })); for (Domain candidate : domains) { if (candidate.getParentDomainId() == null || !names.contains(candidate.getParentDomainName())) { return candidate; } } throw new NoSuchElementException("No root node found in this tree"); } }
private void checkDomain(Domain domain, Domain rootDomain, String expectedName) { assertEquals(domain.getParentDomainId(), rootDomain.getId()); assertEquals(domain.getName(), expectedName); assertEquals(domain.getParentDomainName(), rootDomain.getName()); } }
private void checkDomain(Domain domain, Domain rootDomain, String expectedName) { assertEquals(domain.getParentDomainId(), rootDomain.getId()); assertEquals(domain.getName(), expectedName); assertEquals(domain.getParentDomainName(), rootDomain.getName()); } }
public T fromDomain(Domain in) { return this .id(in.getId()) .hasChild(in.hasChild()) .level(in.getLevel()) .name(in.getName()) .networkDomain(in.getNetworkDomain()) .parentDomainId(in.getParentDomainId()) .parentDomainName(in.getParentDomainName()); } }
public T fromDomain(Domain in) { return this .id(in.getId()) .hasChild(in.hasChild()) .level(in.getLevel()) .name(in.getName()) .networkDomain(in.getNetworkDomain()) .parentDomainId(in.getParentDomainId()) .parentDomainName(in.getParentDomainName()); } }
public T fromDomain(Domain in) { return this .id(in.getId()) .hasChild(in.hasChild()) .level(in.getLevel()) .name(in.getName()) .networkDomain(in.getNetworkDomain()) .parentDomainId(in.getParentDomainId()) .parentDomainName(in.getParentDomainName()); } }