![JAR search and dependency download from the Maven repository](/logo.png)
com.github.stefanbirkner.editors.mapper.CompositeMapper Maven / Gradle / Ivy
package com.github.stefanbirkner.editors.mapper;
/**
* A {@code CompositeMapper} allows you to modify the input and output of a
* arbitrary {@link Mapper}. A second {@code Mapper} is used for mapping the
* input and output.
*
* @author Stefan Birkner
* @param
* the supported type.
* @since 2.0.0
*/
public class CompositeMapper implements Mapper {
private Mapper objectMapper;
private Mapper stringMapper;
public CompositeMapper(Mapper objectMapper, Mapper stringMapper) {
this.objectMapper = objectMapper;
this.stringMapper = stringMapper;
}
public T getValueForText(String text) {
String mappedText = stringMapper.getValueForText(text);
return objectMapper.getValueForText(mappedText);
}
public String getTextForValue(T value) {
String text = objectMapper.getTextForValue(value);
return stringMapper.getTextForValue(text);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy