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

xxl.mathematica.list.First Maven / Gradle / Ivy

package xxl.mathematica.list;

import java.util.List;

/**
 * 第一个
 */

public class First {
    /**
     * 如果存在则给出第一个元素,否则返回def
     *
     * @param list
     * @param def
     * @param 
     * @return
     */
    public static  T first(List list, T def) {
        return io.vavr.collection.List.ofAll(list)
                .headOption()
                .getOrElse(def);
    }

    /**
     * 给出list的第一个元素
     *
     * @param list
     * @param 
     * @return
     */
    public static  T first(List list) {
        return first(list, null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy