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

org.srplib.conversion.adapters.guava.FunctionAdapter Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
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