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

io.lindstrom.mpd.support.Utils Maven / Gradle / Ivy

There is a newer version: 0.13
Show newest version
package io.lindstrom.mpd.support;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Utils {
    public static  List unmodifiableList(List list) {
        if (list == null) {
            return List.of();
        } else {
            return List.copyOf(list);
        }
    }

    @SafeVarargs
    @SuppressWarnings("varargs")
    public static  List varargsToList(T head, T ...tail) {
        if (tail.length == 0) {
            return List.of(head);
        } else {
            List list = new ArrayList<>();
            list.add(head);
            list.addAll(List.of(tail));
            return List.copyOf(list);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy