org.unix4j.convert.CompositeValueConverter Maven / Gradle / Ivy
package org.unix4j.convert;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class CompositeValueConverter implements ValueConverter {
private final List> converters = new ArrayList>();
public CompositeValueConverter() {
super();
}
public CompositeValueConverter(Collection extends ValueConverter extends V>> converters) {
addAll(converters);
}
protected CompositeValueConverter add(ValueConverter extends V> converter) {
this.converters.add(converter);
return this;
}
protected CompositeValueConverter addAll(Collection extends ValueConverter extends V>> converters) {
this.converters.addAll(converters);
return this;
}
@Override
public V convert(Object value) throws IllegalArgumentException {
for (final ValueConverter extends V> converter : converters) {
final V converted = converter.convert(value);
if (converted != null) {
return converted;
}
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy