EnumBasedFeatureProvider implements FeatureProvider { public EnumBasedFeatureProvider addFeatureEnum(Class<? extends Feature> featureEnum) { if (featureEnum == null || !featureEnum.isEnum()) { throw new IllegalArgumentException("The featureEnum argument must be an enum"); } addFeatures(Arrays.asList(featureEnum.getEnumConstants())); return this; } EnumBasedFeatureProvider();  EnumBasedFeatureProvider(Class<? extends Feature>... featureEnums); EnumBasedFeatureProvider addFeatureEnum(Class<? extends Feature> featureEnum); @Override Set<Feature> getFeatures(); @Override FeatureMetaData getMetaData(Feature feature);  }
@Test public void shouldFailForDuplicateFeatureName() { EnumBasedFeatureProvider provider = new EnumBasedFeatureProvider(); provider.addFeatureEnum(ValidFeatureEnum.class); assertThrows(IllegalStateException.class, () -> provider.addFeatureEnum(DuplicateNameFeatureEnum.class)); }