<T extends MaterialConfig> T getExistingOrDefaultMaterial(T defaultMaterial) {
        for (MaterialConfig material : this) {
            if (material.getClass().isAssignableFrom(defaultMaterial.getClass())) {
                return (T) material;
            }
        }
        return defaultMaterial;
    }
@Test
    public void shouldGetExistingOrDefaultPluggableSCMMaterialCorrectly() {
        SvnMaterialConfig svn = svn("http://test.com", false);
        PluggableSCMMaterialConfig pluggableSCMMaterialOne = new PluggableSCMMaterialConfig("scm-id-1");
        PluggableSCMMaterialConfig pluggableSCMMaterialTwo = new PluggableSCMMaterialConfig("scm-id-2");

        assertThat(new MaterialConfigs(svn, pluggableSCMMaterialTwo).getExistingOrDefaultMaterial(pluggableSCMMaterialOne).getScmId()).isEqualTo("scm-id-2");

        assertThat(new MaterialConfigs(svn).getExistingOrDefaultMaterial(pluggableSCMMaterialOne).getScmId()).isEqualTo("scm-id-1");
    }