All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.vergne.pester.options.Option Maven / Gradle / Ivy

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)));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy