add not null entry to list - Android java.util

Android examples for java.util:List Element

Description

add not null entry to list

Demo Code


//package com.java2s;

import java.util.List;

public class Main {
    /**/*  www .j  av  a 2s.c  o  m*/
     * add not null entry to list
     * 
     * @param sourceList
     * @param value
     * @return <ul>
     *         <li>if sourceList is null, return false</li>
     *         <li>if value is null, return false</li>
     *         <li>return {@link List#add(Object)}</li>
     *         </ul>
     */
    public static <V> boolean addListNotNullValue(List<V> sourceList,
            V value) {
        return (sourceList != null && value != null) ? sourceList
                .add(value) : false;
    }
}

Related Tutorials