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

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

Go to download

This command line utility is the Swiss army knife of OSGi. It provides you with a breadth of tools to understand and manage OSGi based systems. This project basically uses bndlib.

There is a newer version: 7.1.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;
	}

	@Override
	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