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

com.jashmore.sqs.util.collections.CollectionUtils Maven / Gradle / Ivy

package com.jashmore.sqs.util.collections;

import lombok.experimental.UtilityClass;

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

/**
 * Collection helper functions that can be used instead of having a Guava dependency.
 */
@UtilityClass
public class CollectionUtils {

    public  List immutableListOf(T element) {
        return Collections.singletonList(element);
    }

    public  List immutableListOf(T one, T two) {
        return Collections.unmodifiableList(Arrays.asList(one, two));
    }

    public  List immutableListOf(T one, T two, T three) {
        return Collections.unmodifiableList(Arrays.asList(one, two, three));
    }

    public  List immutableListOf(T one, T two, T three, T four) {
        return Collections.unmodifiableList(Arrays.asList(one, two, three, four));
    }

    public  List immutableListOf(T one, T two, T three, T four, T five) {
        return Collections.unmodifiableList(Arrays.asList(one, two, three, four, five));
    }

    public  List immutableListFrom(Collection one, Collection two) {
        final List underlyingList = new ArrayList<>(one.size() + two.size());
        underlyingList.addAll(one);
        underlyingList.addAll(two);
        return Collections.unmodifiableList(underlyingList);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy