![JAR search and dependency download from the Maven repository](/logo.png)
com.github.stefanbirkner.editors.mapper.EnumMapper Maven / Gradle / Ivy
package com.github.stefanbirkner.editors.mapper;
import static java.lang.Enum.valueOf;
/**
* An {@code EnumMapper} maps between enums to text and vice versa by using their names.
*
* @author Stefan Birkner
*
* @param
* the supported type.
* @since 2.0.0
*/
public class EnumMapper> implements Mapper {
private final Class type;
public EnumMapper(Class type) {
this.type = type;
}
public E getValueForText(String text) {
return (text == null) ? null : valueOf(type, text);
}
public String getTextForValue(E value) {
return (value == null) ? null : value.name();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy