Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2013
 *
 * 52North Initiative for Geospatial Open Source Software GmbH
 * Contact: Andreas Wytzisk
 * Martin-Luther-King-Weg 24
 * 48155 Muenster, Germany
 * info@52north.org
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import java.util.Collection;

import java.util.Map;

public class Main {
    /**
     * Check if collection is not null and not empty
     * 
     * @param collection
     *            Collection to check
     *            
     * @return empty or not
     */
    public static <T> boolean isNotEmpty(final Collection<T> collection) {
        return collection != null && !collection.isEmpty();
    }

    /**
     * Check if collection is not null and not empty
     * 
     * 
     * @param map
     *          Map to check
     * 
     * @return <tt>false</tt>, if map is <tt>null</tt> or empty, else <tt>true</tt>. 
     */
    public static <K, V> boolean isNotEmpty(final Map<K, V> map) {
        return map != null && !map.isEmpty();
    }

    /**
     * Check if collection is not <tt>null</tt> and empty
     * 
     * @param collection
     *          Collection to check
     * 
     * @return <tt>true</tt>, if collection is not null and empty, else <tt>false</tt>
     */
    public static <T> boolean isEmpty(final Collection<T> collection) {
        return collection != null && collection.isEmpty();
    }

    /**
     * Check if map is not <tt>null</tt> and empty
     * 
     * @param map
     *          map to check
     * 
     * @return <tt>true</tt>, if map is not null and empty, else <tt>false</tt>
     */
    public static <K, V> boolean isEmpty(final Map<K, V> map) {
        return map != null && map.isEmpty();
    }
}