fr.vergne.pester.options.Option Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pester-core Show documentation
Show all versions of pester-core Show documentation
Implementation of the Pester library.
The newest version!
package fr.vergne.pester.options;
import java.util.stream.Stream;
public interface Option {
public boolean testModifiers(int modifiers);
public static E getFromModifiers(int modifiers, Class optionClass) {
return Stream.of(optionClass.getEnumConstants())
.filter(v -> v.testModifiers(modifiers))
.findFirst()
.orElseThrow(() -> new RuntimeException(String.format("No %s corresponds to modifiers: %d", optionClass.getSimpleName(), modifiers)));
}
}