public boolean isAncestorOf(ResourceGroupId descendant)
    {
        List<String> descendantSegments = descendant.getSegments();
        if (segments.size() >= descendantSegments.size()) {
            return false;
        }
        return descendantSegments.subList(0, segments.size()).equals(segments);
    }
@Test
    public void testIsAncestor()
    {
        ResourceGroupId root = new ResourceGroupId("root");
        ResourceGroupId rootA = new ResourceGroupId(root, "a");
        ResourceGroupId rootAFoo = new ResourceGroupId(rootA, "foo");
        ResourceGroupId rootBar = new ResourceGroupId(root, "bar");
        assertTrue(root.isAncestorOf(rootA));
        assertTrue(root.isAncestorOf(rootAFoo));
        assertTrue(root.isAncestorOf(rootBar));
        assertTrue(rootA.isAncestorOf(rootAFoo));
        assertFalse(rootA.isAncestorOf(rootBar));
        assertFalse(rootAFoo.isAncestorOf(rootBar));
        assertFalse(rootBar.isAncestorOf(rootAFoo));
        assertFalse(rootAFoo.isAncestorOf(root));
        assertFalse(root.isAncestorOf(root));
        assertFalse(rootAFoo.isAncestorOf(rootAFoo));
    }