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

com.caoccao.javet.swc4j.utils.SimpleList Maven / Gradle / Ivy

Go to download

swc4j (SWC for Java) is an ultra-fast JavaScript and TypeScript compilation and bundling tool on JVM.

The newest version!
/*
 * Copyright (c) 2023-2024. caoccao.com Sam Cao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.caoccao.javet.swc4j.utils;

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

/**
 * The type Simple list.
 *
 * @since 0.2.0
 */
public final class SimpleList {
    private SimpleList() {
    }

    /**
     * Copy of list.
     *
     * @param         the type parameter
     * @param         the type parameter
     * @param collection the collection
     * @return the copied list
     * @since 0.2.0
     */
    public static  List copyOf(Collection collection) {
        return new ArrayList<>(collection);
    }

    /**
     * Get an immutable list.
     *
     * @param   the type parameter
     * @param list the list
     * @return the list
     * @since 0.2.0
     */
    public static  List immutable(List list) {
        return Collections.unmodifiableList(list);
    }

    /**
     * Immutable copy of list.
     *
     * @param         the type parameter
     * @param         the type parameter
     * @param collection the collection
     * @return the immutable copied list
     * @since 0.2.0
     */
    public static  List immutableCopyOf(Collection collection) {
        return immutable(copyOf(collection));
    }

    /**
     * Immutable of list.
     *
     * @param  the type parameter
     * @return the immutable list
     * @since 0.2.0
     */
    public static  List immutableOf() {
        return immutable(of());
    }

    /**
     * Immutable of list.
     *
     * @param      the type parameter
     * @param objects the objects
     * @return the immutable list
     * @since 0.2.0
     */
    @SafeVarargs
    public static  List immutableOf(T... objects) {
        return immutable(of(objects));
    }

    /**
     * Of list.
     *
     * @param  the type parameter
     * @return the list
     * @since 0.2.0
     */
    public static  List of() {
        return new ArrayList<>();
    }

    /**
     * Of list.
     *
     * @param      the type parameter
     * @param objects the objects
     * @return the list
     * @since 0.2.0
     */
    @SafeVarargs
    public static  List of(T... objects) {
        List list = new ArrayList<>();
        Collections.addAll(list, objects);
        return list;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy