Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

import java.util.Collection;
import java.util.Collections;

import java.util.List;
import java.util.Map;

public class Main {

    public static <V> List<V> uniteCollections(Collection<? extends Collection<V>> values) {
        if (isEmpty(values)) {
            return Collections.emptyList();
        }
        List<V> copy = new ArrayList<V>();
        for (Collection<V> collection : values) {
            copy.addAll(collection);
        }
        return copy;
    }

    public static boolean isEmpty(Map<?, ?> test) {
        return !isNotEmpty(test);
    }

    public static boolean isEmpty(Collection<?> test) {
        return !isNotEmpty(test);
    }

    public static boolean isEmpty(Object[] test) {
        return !isNotEmpty(test);
    }

    public static boolean isNotEmpty(Map<?, ?> test) {
        return test != null && !test.isEmpty();
    }

    public static boolean isNotEmpty(Collection<?> test) {
        return test != null && !test.isEmpty();
    }

    public static boolean isNotEmpty(Object[] test) {
        return test != null && test.length > 0;
    }
}