Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) 2006-2015 phloc systems
* http://www.phloc.com
* office[at]phloc[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.phloc.commons.collections;//NOPMD
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.phloc.commons.ValueEnforcer;
import com.phloc.commons.annotations.ReturnsImmutableObject;
import com.phloc.commons.annotations.ReturnsMutableCopy;
import com.phloc.commons.annotations.ReturnsMutableObject;
import com.phloc.commons.collections.iterate.CombinedEnumeration;
import com.phloc.commons.collections.iterate.CombinedIterator;
import com.phloc.commons.collections.iterate.EmptyEnumeration;
import com.phloc.commons.collections.iterate.EmptyIterator;
import com.phloc.commons.collections.iterate.EnumerationFromIterator;
import com.phloc.commons.collections.iterate.IIterableIterator;
import com.phloc.commons.collections.iterate.IterableIteratorFromEnumeration;
import com.phloc.commons.collections.iterate.ReverseListIterator;
import com.phloc.commons.collections.multimap.IMultiMap;
import com.phloc.commons.collections.multimap.IMultiMapSetBased;
import com.phloc.commons.collections.multimap.MultiHashMapHashSetBased;
import com.phloc.commons.compare.ComparatorComparableNullAware;
import com.phloc.commons.compare.ComparatorUtils;
import com.phloc.commons.compare.ESortOrder;
import com.phloc.commons.state.EChange;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Provides various helper methods to handle collections like {@link List},
* {@link Set} and {@link Map}.
*
* @author Philip Helger
* @author Boris Gregorcic
*/
@Immutable
public final class ContainerHelper
{
private ContainerHelper ()
{
// private
}
@Nonnull
public static List extends ELEMENTTYPE> getNotNull (final List extends ELEMENTTYPE> aList)
{
return aList == null ? ContainerHelper. newList () : aList;
}
@Nonnull
public static Set extends ELEMENTTYPE> getNotNull (final Set extends ELEMENTTYPE> aSet)
{
return aSet == null ? ContainerHelper. newSet () : aSet;
}
@Nonnull
public static > SortedSet extends ELEMENTTYPE> getNotNull (final SortedSet extends ELEMENTTYPE> aSortedSet)
{
return aSortedSet == null ? ContainerHelper. newSortedSet () : aSortedSet;
}
@Nonnull
public static Map extends KEYTYPE, ? extends VALUETYPE> getNotNull (final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
return aMap == null ? ContainerHelper. newMap () : aMap;
}
@Nonnull
public static , VALUETYPE> SortedMap extends KEYTYPE, ? extends VALUETYPE> getNotNull (final SortedMap extends KEYTYPE, ? extends VALUETYPE> aSortedMap)
{
return aSortedMap == null ? ContainerHelper. newSortedMap () : aSortedMap;
}
@Nullable
@ReturnsImmutableObject
public static Collection makeUnmodifiable (@Nullable final Collection extends ELEMENTTYPE> aCollection)
{
return aCollection == null ? null : Collections.unmodifiableCollection (aCollection);
}
@Nullable
@ReturnsImmutableObject
public static List makeUnmodifiable (@Nullable final List extends ELEMENTTYPE> aList)
{
return aList == null ? null : Collections.unmodifiableList (aList);
}
@Nullable
@ReturnsImmutableObject
public static Set makeUnmodifiable (@Nullable final Set extends ELEMENTTYPE> aSet)
{
return aSet == null ? null : Collections.unmodifiableSet (aSet);
}
@Nullable
@ReturnsImmutableObject
public static Map makeUnmodifiable (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
return aMap == null ? null : Collections.unmodifiableMap (aMap);
}
@Nullable
@ReturnsImmutableObject
public static > SortedSet makeUnmodifiable (@Nullable final SortedSet aSortedSet)
{
return aSortedSet == null ? null : Collections.unmodifiableSortedSet (aSortedSet);
}
@Nullable
@ReturnsImmutableObject
public static SortedMap makeUnmodifiable (@Nullable final SortedMap aSortedMap)
{
return aSortedMap == null ? null : Collections.unmodifiableSortedMap (aSortedMap);
}
@Nonnull
@ReturnsImmutableObject
public static Collection makeUnmodifiableNotNull (@Nullable final Collection extends ELEMENTTYPE> aCollection)
{
return aCollection == null ? ContainerHelper. newUnmodifiableList ()
: Collections.unmodifiableCollection (aCollection);
}
@Nonnull
@ReturnsImmutableObject
public static List makeUnmodifiableNotNull (@Nullable final List extends ELEMENTTYPE> aList)
{
return aList == null ? ContainerHelper. newUnmodifiableList () : Collections.unmodifiableList (aList);
}
@Nonnull
@ReturnsImmutableObject
public static Set makeUnmodifiableNotNull (@Nullable final Set extends ELEMENTTYPE> aSet)
{
return aSet == null ? ContainerHelper. newUnmodifiableSet () : Collections.unmodifiableSet (aSet);
}
@Nonnull
@ReturnsImmutableObject
public static Map makeUnmodifiableNotNull (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
return aMap == null ? ContainerHelper. newUnmodifiableMap ()
: Collections.unmodifiableMap (aMap);
}
@Nonnull
@ReturnsImmutableObject
public static > SortedSet makeUnmodifiableNotNull (@Nullable final SortedSet aSortedSet)
{
return aSortedSet == null ? ContainerHelper. newUnmodifiableSortedSet ()
: Collections.unmodifiableSortedSet (aSortedSet);
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap makeUnmodifiableNotNull (@Nullable final SortedMap aSortedMap)
{
return Collections.unmodifiableSortedMap (aSortedMap == null ? ContainerHelper. newSortedMap ()
: aSortedMap);
}
/**
* Get all elements that are only contained in the first contained, and not in
* the second. This method implements aCont1 - aCont2.
*
* @param aCollection1
* The first container. May be null or empty.
* @param aCollection2
* The second container. May be null or empty.
* @return The difference and never null. Returns an empty set,
* if the first container is empty. Returns a copy of the first
* container, if the second container is empty. Returns
* aCont1 - aCont2 if both containers are non-empty.
*/
@Nullable
@ReturnsMutableCopy
public static Set getDifference (@Nullable final Collection extends ELEMENTTYPE> aCollection1,
@Nullable final Collection extends ELEMENTTYPE> aCollection2)
{
if (isEmpty (aCollection1))
return newSet ();
if (isEmpty (aCollection2))
return newSet (aCollection1);
final Set ret = newSet (aCollection1);
ret.removeAll (aCollection2);
return ret;
}
/**
* Get all elements that are contained in the first AND in the second
* container.
*
* @param aCollection1
* The first container. May be null or empty.
* @param aCollection2
* The second container. May be null or empty.
* @return An empty set, if either the first or the second container are
* empty. Returns a set of elements that are contained in both
* containers, if both containers are non-empty. The return value is
* never null.
*/
@Nullable
@ReturnsMutableCopy
public static Set getIntersected (@Nullable final Collection extends ELEMENTTYPE> aCollection1,
@Nullable final Collection extends ELEMENTTYPE> aCollection2)
{
if (isEmpty (aCollection1))
return newSet ();
if (isEmpty (aCollection2))
return newSet ();
final Set ret = newSet (aCollection1);
ret.retainAll (aCollection2);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap ()
{
return new HashMap (0);
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
final Map ret = new HashMap (1);
ret.put (aKey, aValue);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final ELEMENTTYPE... aValues)
{
if (ArrayHelper.isEmpty (aValues))
return new HashMap (0);
if ((aValues.length % 2) != 0)
throw new IllegalArgumentException ("The passed array needs an even number of elements!"); //$NON-NLS-1$
final Map ret = new HashMap (aValues.length / 2);
for (int i = 0; i < aValues.length; i += 2)
ret.put (aValues[i], aValues[i + 1]);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
// Are both empty?
if (ArrayHelper.isEmpty (aKeys) && ArrayHelper.isEmpty (aValues))
return new HashMap (0);
// keys OR values may be null here
if (ArrayHelper.getSize (aKeys) != ArrayHelper.getSize (aValues))
throw new IllegalArgumentException ("The passed arrays have different length!"); //$NON-NLS-1$
final Map ret = new HashMap (aKeys.length);
for (int i = 0; i < aKeys.length; ++i)
ret.put (aKeys[i], aValues[i]);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
// Are both empty?
if (isEmpty (aKeys) && isEmpty (aValues))
return new HashMap (0);
// keys OR values may be null here
if (getSize (aKeys) != getSize (aValues))
throw new IllegalArgumentException ("Number of keys is different from number of values"); //$NON-NLS-1$
final Map ret = new HashMap (aKeys.size ());
final Iterator extends KEYTYPE> itk = aKeys.iterator ();
final Iterator extends VALUETYPE> itv = aValues.iterator ();
while (itk.hasNext ())
ret.put (itk.next (), itv.next ());
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
if (isEmpty (aMap))
return new HashMap (0);
return new HashMap (aMap);
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> [] aMaps)
{
if (aMaps == null || aMaps.length == 0)
return new HashMap (0);
final Map ret = new HashMap ();
for (final Map extends KEYTYPE, ? extends VALUETYPE> aMap : aMaps)
ret.putAll (aMap);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newMap (@Nullable final Collection extends Map.Entry > aCollection)
{
if (isEmpty (aCollection))
return new HashMap (0);
final Map ret = new HashMap (aCollection.size ());
for (final Map.Entry aEntry : aCollection)
ret.put (aEntry.getKey (), aEntry.getValue ());
return ret;
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap ()
{
return Collections. emptyMap ();
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
return Collections.singletonMap (aKey, aValue);
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final ELEMENTTYPE... aValues)
{
return makeUnmodifiable (newMap (aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
return makeUnmodifiable (newMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
return makeUnmodifiable (newMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
return makeUnmodifiable (aMap);
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> [] aMaps)
{
return makeUnmodifiable (newMap (aMaps));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableMap (@Nullable final Collection extends Map.Entry > aCollection)
{
return makeUnmodifiable (newMap (aCollection));
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap ()
{
return new LinkedHashMap (0);
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
final Map ret = new LinkedHashMap (1);
ret.put (aKey, aValue);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final ELEMENTTYPE... aValues)
{
if (ArrayHelper.isEmpty (aValues))
return new LinkedHashMap (0);
if ((aValues.length % 2) != 0)
throw new IllegalArgumentException ("The passed array needs an even number of elements!"); //$NON-NLS-1$
final Map ret = new LinkedHashMap (aValues.length / 2);
for (int i = 0; i < aValues.length; i += 2)
ret.put (aValues[i], aValues[i + 1]);
return ret;
}
/**
* Retrieve a map that is ordered in the way the parameter arrays are passed
* in. Note that key and value arrays need to have the same length.
*
* @param
* The key type.
* @param
* The value type.
* @param aKeys
* The key array to use. May not be null.
* @param aValues
* The value array to use. May not be null.
* @return A {@link java.util.LinkedHashMap} containing the passed key-value
* entries. Never null.
*/
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
// Are both empty?
if (ArrayHelper.isEmpty (aKeys) && ArrayHelper.isEmpty (aValues))
return new LinkedHashMap (0);
// keys OR values may be null here
if (ArrayHelper.getSize (aKeys) != ArrayHelper.getSize (aValues))
throw new IllegalArgumentException ("The passed arrays have different length!"); //$NON-NLS-1$
final Map ret = new LinkedHashMap (aKeys.length);
for (int i = 0; i < aKeys.length; ++i)
ret.put (aKeys[i], aValues[i]);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
// Are both empty?
if (isEmpty (aKeys) && isEmpty (aValues))
return new LinkedHashMap (0);
// keys OR values may be null here
if (getSize (aKeys) != getSize (aValues))
throw new IllegalArgumentException ("Number of keys is different from number of values"); //$NON-NLS-1$
final Map ret = new LinkedHashMap (aKeys.size ());
final Iterator extends KEYTYPE> itk = aKeys.iterator ();
final Iterator extends VALUETYPE> itv = aValues.iterator ();
while (itk.hasNext ())
ret.put (itk.next (), itv.next ());
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
if (isEmpty (aMap))
return new LinkedHashMap (0);
return new LinkedHashMap (aMap);
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> [] aMaps)
{
if (aMaps == null || aMaps.length == 0)
return new LinkedHashMap (0);
final Map ret = new LinkedHashMap ();
for (final Map extends KEYTYPE, ? extends VALUETYPE> aMap : aMaps)
ret.putAll (aMap);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Map newOrderedMap (@Nullable final Collection extends Map.Entry > aCollection)
{
if (isEmpty (aCollection))
return new LinkedHashMap (0);
final Map ret = new LinkedHashMap (aCollection.size ());
for (final Map.Entry aEntry : aCollection)
ret.put (aEntry.getKey (), aEntry.getValue ());
return ret;
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap ()
{
return Collections. emptyMap ();
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
return Collections.singletonMap (aKey, aValue);
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final ELEMENTTYPE... aValues)
{
return makeUnmodifiable (newOrderedMap (aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
return makeUnmodifiable (newOrderedMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
return makeUnmodifiable (newOrderedMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aOrderedMap)
{
return makeUnmodifiable (aOrderedMap);
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> [] aOrderedMaps)
{
return makeUnmodifiable (newOrderedMap (aOrderedMaps));
}
@Nonnull
@ReturnsImmutableObject
public static Map newUnmodifiableOrderedMap (@Nullable final Collection extends Map.Entry > aCollection)
{
return makeUnmodifiable (newOrderedMap (aCollection));
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap ()
{
return new TreeMap (new ComparatorComparableNullAware ());
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
ret.put (aKey, aValue);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static > TreeMap newSortedMap (@Nullable final ELEMENTTYPE... aValues)
{
if (ArrayHelper.isEmpty (aValues))
return new TreeMap (new ComparatorComparableNullAware ());
if ((aValues.length % 2) != 0)
throw new IllegalArgumentException ("The passed array needs an even number of elements!"); //$NON-NLS-1$
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
for (int i = 0; i < aValues.length; i += 2)
ret.put (aValues[i], aValues[i + 1]);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
// Are both empty?
if (ArrayHelper.isEmpty (aKeys) && ArrayHelper.isEmpty (aValues))
return new TreeMap (new ComparatorComparableNullAware ());
// keys OR values may be null here
if (ArrayHelper.getSize (aKeys) != ArrayHelper.getSize (aValues))
throw new IllegalArgumentException ("The passed arrays have different length!"); //$NON-NLS-1$
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
for (int i = 0; i < aKeys.length; ++i)
ret.put (aKeys[i], aValues[i]);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
// Are both empty?
if (isEmpty (aKeys) && isEmpty (aValues))
return new TreeMap (new ComparatorComparableNullAware ());
// keys OR values may be null here
if (getSize (aKeys) != getSize (aValues))
throw new IllegalArgumentException ("Number of keys is different from number of values"); //$NON-NLS-1$
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
final Iterator extends KEYTYPE> itk = aKeys.iterator ();
final Iterator extends VALUETYPE> itv = aValues.iterator ();
while (itk.hasNext ())
ret.put (itk.next (), itv.next ());
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> aMap)
{
if (isEmpty (aMap))
return new TreeMap (new ComparatorComparableNullAware ());
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
ret.putAll (aMap);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final Map extends KEYTYPE, ? extends VALUETYPE> [] aMaps)
{
if (aMaps == null || aMaps.length == 0)
return new TreeMap (new ComparatorComparableNullAware ());
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
for (final Map extends KEYTYPE, ? extends VALUETYPE> aMap : aMaps)
ret.putAll (aMap);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static , VALUETYPE> TreeMap newSortedMap (@Nullable final Collection extends Map.Entry > aCollection)
{
if (isEmpty (aCollection))
return new TreeMap (new ComparatorComparableNullAware ());
final TreeMap ret = new TreeMap (new ComparatorComparableNullAware ());
for (final Map.Entry aEntry : aCollection)
ret.put (aEntry.getKey (), aEntry.getValue ());
return ret;
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap ()
{
return makeUnmodifiable (ContainerHelper. newSortedMap ());
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final KEYTYPE aKey,
@Nullable final VALUETYPE aValue)
{
return makeUnmodifiable (newSortedMap (aKey, aValue));
}
@Nonnull
@ReturnsImmutableObject
public static > SortedMap newUnmodifiableSortedMap (@Nullable final ELEMENTTYPE... aValues)
{
return makeUnmodifiable (newSortedMap (aValues));
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final KEYTYPE [] aKeys,
@Nullable final VALUETYPE [] aValues)
{
return makeUnmodifiable (newSortedMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final Collection extends KEYTYPE> aKeys,
@Nullable final Collection extends VALUETYPE> aValues)
{
return makeUnmodifiable (newSortedMap (aKeys, aValues));
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final SortedMap aMap)
{
return makeUnmodifiable (aMap);
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final Map [] aMaps)
{
return makeUnmodifiable (newSortedMap (aMaps));
}
@Nonnull
@ReturnsImmutableObject
public static , VALUETYPE> SortedMap newUnmodifiableSortedMap (@Nullable final Collection extends Map.Entry > aCollection)
{
return makeUnmodifiable (newSortedMap (aCollection));
}
@Nonnull
@ReturnsMutableCopy
public static Set newSet ()
{
return new HashSet (0);
}
@Nonnull
@ReturnsMutableCopy
public static Set newSet (@Nullable final ELEMENTTYPE aValue)
{
final Set ret = new HashSet (1);
ret.add (aValue);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Set newSet (@Nullable final ELEMENTTYPE... aValues)
{
if (ArrayHelper.isEmpty (aValues))
return new HashSet (0);
final Set ret = new HashSet (aValues.length);
Collections.addAll (ret, aValues);
return ret;
}
@Nonnull
@ReturnsMutableCopy
public static Set newSet (@Nullable final Iterable extends ELEMENTTYPE> aCont)
{
final Set