nl.vpro.hibernate.search6.IterableToStringBridge Maven / Gradle / Ivy
package nl.vpro.hibernate.search6;
import org.hibernate.search.mapper.pojo.bridge.ValueBridge;
import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeToIndexedValueContext;
import java.util.ArrayList;
import java.util.List;
/**
* @author Michiel Meeuwissen
* @since 1.10
*/
public abstract class IterableToStringBridge implements ValueBridge, List> {
@Override
public List toIndexedValue(Iterable value, ValueBridgeToIndexedValueContext valueBridgeToIndexedValueContext) {
if (value != null) {
List result = new ArrayList<>();
for (T object : value) {
if (object != null) {
result.add(toString(object));
}
}
return result;
} else {
return null;
}
}
protected abstract String toString(T object);
}