org.srplib.conversion.adapters.guava.FunctionAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of srp-conversion-support Show documentation
Show all versions of srp-conversion-support Show documentation
Single Responsibility Principle (SRP) libraries collection
package org.srplib.conversion.adapters.guava;
import org.srplib.contract.Argument;
import org.srplib.conversion.Converter;
import com.google.common.base.Function;
/**
* A adapter for google core libraries known as Guava project (http://code.google.com/p/guava-libraries).
*
* FunctionAdapter wraps {@link Converter} to implementation of {@link Function}. FunctionAdapter is a good way to reuse
* existing converters with rich set of utility methods of Guava project}.
*
*
* Converter converter = ....
* ...
* Collection result = Collections2.transform(collection, new FunctionAdapter(converter));
*
*
*
* @author Anton Pechinsky
*/
public class FunctionAdapter implements Function {
private Converter converter;
public FunctionAdapter(Converter converter) {
Argument.checkNotNull(converter, "Converter should not be null!");
this.converter = converter;
}
@Override
public O apply(I input) {
return converter.convert(input);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy