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

aQute.bnd.build.model.conversions.EnumConverter Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
package aQute.bnd.build.model.conversions;

public class EnumConverter> implements Converter {

	private final Class	enumType;
	private final E			defaultValue;

	public static > EnumConverter create(Class enumType) {
		return new EnumConverter(enumType, null);
	}

	public static > EnumConverter create(Class enumType, E defaultValue) {
		return new EnumConverter(enumType, defaultValue);
	}

	private EnumConverter(Class enumType, E defaultValue) {
		this.enumType = enumType;
		this.defaultValue = defaultValue;
	}

	public E convert(String input) throws IllegalArgumentException {
		if (input == null)
			return defaultValue;
		return Enum.valueOf(enumType, input);
	}

	@Override
	public E error(String msg) {
		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy