Java tutorial
//package com.java2s; // The contents of this file are subject to the Mozilla Public License import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; public class Main { /** * Provides a wrapper to create a list out of a collection * @param wrappedCollection nullable collection * @param <T> type parameter of collection and resulting list * @return list of Ts from wrappedCollection or empty list */ @Nonnull public static <T> List<T> listFrom(@Nullable Collection<T> wrappedCollection) { if (wrappedCollection == null || wrappedCollection.isEmpty()) { return new ArrayList<T>(); } else { return new ArrayList<T>(wrappedCollection); } } }