Java tutorial
//package com.java2s; /* * Hibernate OGM, Domain model persistence for NoSQL datastores * * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. */ import java.util.Collections; import java.util.HashSet; import java.util.Set; public class Main { /** * Returns an unmodifiable set containing the given elements. * * @param ts the elements from which to create a set * @param <T> the type of the element in the set * @return an unmodifiable set containing the given elements or {@code null} in case the given element array is * {@code null}. */ public static <T> Set<T> asSet(T... ts) { if (ts == null) { return null; } else if (ts.length == 0) { return Collections.emptySet(); } else { Set<T> set = new HashSet<T>(ts.length); Collections.addAll(set, ts); return Collections.unmodifiableSet(set); } } }