All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.unix4j.convert.CompositeValueConverter Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
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> converters) {
		addAll(converters);
	}
	protected CompositeValueConverter add(ValueConverter converter) {
		this.converters.add(converter);
		return this;
	}
	protected CompositeValueConverter addAll(Collection> converters) {
		this.converters.addAll(converters);
		return this;
	}
	@Override
	public V convert(Object value) throws IllegalArgumentException {
		for (final ValueConverter converter : converters) {
			final V converted = converter.convert(value);
			if (converted != null) {
				return converted;
			}
		}
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy