public OptionalInt getFirstDynamicSegment()
    {
        return IntStream.range(0, segments.size())
                .filter(i -> segments.get(i).hasVariables())
                .findFirst();
    }
@Test
    public void testFirstDynamicSegment()
    {
        ResourceGroupIdTemplate template = new ResourceGroupIdTemplate("test.${USER}.${SOURCE}");
        assertEquals(template.getFirstDynamicSegment(), OptionalInt.of(1));
        template = new ResourceGroupIdTemplate("test.pipeline.job_${pipeline}_user:${USER}.${USER}");
        assertEquals(template.getFirstDynamicSegment(), OptionalInt.of(2));
    }