All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.helger.commons.collection.PrimitiveCollectionHelper Maven / Gradle / Ivy

There is a newer version: 11.1.10
Show newest version
/*
 * Copyright (C) 2014-2024 Philip Helger (www.helger.com)
 * philip[at]helger[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.helger.commons.collection;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.commons.annotation.ReturnsMutableCopy;
import com.helger.commons.collection.impl.CommonsArrayList;
import com.helger.commons.collection.impl.CommonsHashSet;
import com.helger.commons.collection.impl.CommonsLinkedHashSet;
import com.helger.commons.collection.impl.CommonsTreeSet;

/**
 * Collection helper for primitive data types (boolean, byte, char, double,
 * float, int, long and short).
 *
 * @author Philip Helger
 */
public final class PrimitiveCollectionHelper
{
  private PrimitiveCollectionHelper ()
  {}

  // The code below is generated by MainCreateCollectionHelperCode

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final boolean... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final boolean aValue : aValues)
        ret.add (Boolean.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final byte... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final byte aValue : aValues)
        ret.add (Byte.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final char... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final char aValue : aValues)
        ret.add (Character.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final double... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final double aValue : aValues)
        ret.add (Double.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final float... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final float aValue : aValues)
        ret.add (Float.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final int... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final int aValue : aValues)
        ret.add (Integer.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final long... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final long aValue : aValues)
        ret.add (Long.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsArrayList  newPrimitiveList (@Nullable final short... aValues)
  {
    final CommonsArrayList  ret = new CommonsArrayList <> ();
    if (aValues != null)
      for (final short aValue : aValues)
        ret.add (Short.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final boolean... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final boolean aValue : aValues)
        ret.add (Boolean.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final byte... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final byte aValue : aValues)
        ret.add (Byte.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final char... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final char aValue : aValues)
        ret.add (Character.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final double... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final double aValue : aValues)
        ret.add (Double.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final float... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final float aValue : aValues)
        ret.add (Float.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final int... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final int aValue : aValues)
        ret.add (Integer.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final long... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final long aValue : aValues)
        ret.add (Long.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsHashSet  newPrimitiveSet (@Nullable final short... aValues)
  {
    final CommonsHashSet  ret = new CommonsHashSet <> ();
    if (aValues != null)
      for (final short aValue : aValues)
        ret.add (Short.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final boolean... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final boolean aValue : aValues)
        ret.add (Boolean.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final byte... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final byte aValue : aValues)
        ret.add (Byte.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final char... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final char aValue : aValues)
        ret.add (Character.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final double... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final double aValue : aValues)
        ret.add (Double.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final float... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final float aValue : aValues)
        ret.add (Float.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final int... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final int aValue : aValues)
        ret.add (Integer.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final long... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final long aValue : aValues)
        ret.add (Long.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsLinkedHashSet  newPrimitiveOrderedSet (@Nullable final short... aValues)
  {
    final CommonsLinkedHashSet  ret = new CommonsLinkedHashSet <> ();
    if (aValues != null)
      for (final short aValue : aValues)
        ret.add (Short.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final boolean... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final boolean aValue : aValues)
        ret.add (Boolean.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final byte... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final byte aValue : aValues)
        ret.add (Byte.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final char... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final char aValue : aValues)
        ret.add (Character.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final double... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final double aValue : aValues)
        ret.add (Double.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final float... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final float aValue : aValues)
        ret.add (Float.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final int... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final int aValue : aValues)
        ret.add (Integer.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final long... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final long aValue : aValues)
        ret.add (Long.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static CommonsTreeSet  newPrimitiveSortedSet (@Nullable final short... aValues)
  {
    final CommonsTreeSet  ret = new CommonsTreeSet <> ();
    if (aValues != null)
      for (final short aValue : aValues)
        ret.add (Short.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final boolean... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final boolean aValue : aValues)
        ret.add (Boolean.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final byte... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final byte aValue : aValues)
        ret.add (Byte.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final char... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final char aValue : aValues)
        ret.add (Character.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final double... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final double aValue : aValues)
        ret.add (Double.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final float... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final float aValue : aValues)
        ret.add (Float.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final int... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final int aValue : aValues)
        ret.add (Integer.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final long... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final long aValue : aValues)
        ret.add (Long.valueOf (aValue));
    return ret;
  }

  @Nonnull
  @ReturnsMutableCopy
  public static NonBlockingStack  newPrimitiveStack (@Nullable final short... aValues)
  {
    final NonBlockingStack  ret = new NonBlockingStack <> ();
    if (aValues != null)
      for (final short aValue : aValues)
        ret.add (Short.valueOf (aValue));
    return ret;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy