aQute.bnd.build.model.conversions.EnumConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz.aQute.bnd Show documentation
Show all versions of biz.aQute.bnd Show documentation
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.
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;
}
}