Here you can find the source of asSet(T... ts)
Parameter | Description |
---|---|
ts | the elements from which to create a set |
T | the type of the element in the set |
public static <T> Set<T> asSet(T... ts)
//package com.java2s; /*/*from w w w . j ava2s . c o m*/ * 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); } } }