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

org.openstack4j.openstack.common.functions.OneOrNull Maven / Gradle / Ivy

package org.openstack4j.openstack.common.functions;

import java.util.List;

import com.google.common.base.Function;

/**
 * A Function which returns one entry from a List or null
 * @author Jeremy Unruh
 * 
 * @param  The return Type
 */
public class OneOrNull implements Function, T> {

    public static  OneOrNull create() {
        return new OneOrNull();
    }
     
    @Override
    public T apply(List input) {
        if (input != null && input.size() > 0)
            return input.get(0);
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy