ArrayBuilders
Date: 2016-12-04

com.fasterxml.jackson.databind.util

## Class ArrayBuilders

- java.lang.Object
- - com.fasterxml.jackson.databind.util.ArrayBuilders

-     public final class ArrayBuilders
      extends java.lang.Object

  Helper class that contains set of distinct builders for different arrays of primitive values. It also provides trivially simple reuse scheme, which assumes that caller knows not to use instances concurrently (which works ok with primitive arrays since they can not contain other non-primitive types). Also note that instances are not thread safe; the intent is that a builder is constructed on per-call (deserialization) basis.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ArrayBuilders.BooleanBuilder`
    `static class` | `ArrayBuilders.ByteBuilder`
    `static class` | `ArrayBuilders.DoubleBuilder`
    `static class` | `ArrayBuilders.FloatBuilder`
    `static class` | `ArrayBuilders.IntBuilder`
    `static class` | `ArrayBuilders.LongBuilder`
    `static class` | `ArrayBuilders.ShortBuilder`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ArrayBuilders()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> java.util.List<T>` | `addToList(java.util.List<T> list, T element)` Helper method for adding specified element to a List, but also considering case where the List may not have been yet constructed (that is, null is passed instead).
    `static <T> java.util.ArrayList<T>` | `arrayToList(T[] elements)`
    `static <T> java.util.HashSet<T>` | `arrayToSet(T[] elements)`
    `static java.lang.Object` | `getArrayComparator(java.lang.Object defaultValue)` Helper method used for constructing simple value comparator used for comparing arrays for content equality.
    `ArrayBuilders.BooleanBuilder` | `getBooleanBuilder()`
    `ArrayBuilders.ByteBuilder` | `getByteBuilder()`
    `ArrayBuilders.DoubleBuilder` | `getDoubleBuilder()`
    `ArrayBuilders.FloatBuilder` | `getFloatBuilder()`
    `ArrayBuilders.IntBuilder` | `getIntBuilder()`
    `ArrayBuilders.LongBuilder` | `getLongBuilder()`
    `ArrayBuilders.ShortBuilder` | `getShortBuilder()`
    `static <T> T[]` | `insertInList(T[] array, T element)` Helper method for constructing a new array that contains specified element followed by contents of the given array.
    `static <T> T[]` | `insertInListNoDup(T[] array, T element)` Helper method for constructing a new array that contains specified element followed by contents of the given array but never contains duplicates.
    `static <T> java.util.HashSet<T>` | `setAndArray(java.util.Set<T> set, T[] elements)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ArrayBuilders

          public ArrayBuilders()

  - ### Method Detail

    - #### getBooleanBuilder

          public ArrayBuilders.BooleanBuilder getBooleanBuilder()

    - #### getByteBuilder

          public ArrayBuilders.ByteBuilder getByteBuilder()

    - #### getShortBuilder

          public ArrayBuilders.ShortBuilder getShortBuilder()

    - #### getIntBuilder

          public ArrayBuilders.IntBuilder getIntBuilder()

    - #### getLongBuilder

          public ArrayBuilders.LongBuilder getLongBuilder()

    - #### getFloatBuilder

          public ArrayBuilders.FloatBuilder getFloatBuilder()

    - #### getDoubleBuilder

          public ArrayBuilders.DoubleBuilder getDoubleBuilder()

    - #### getArrayComparator

          public static java.lang.Object getArrayComparator(java.lang.Object defaultValue)

      Helper method used for constructing simple value comparator used for comparing arrays for content equality.

      Note: current implementation is not optimized for speed; if performance ever becomes an issue, it is possible to construct much more efficient typed instances (one for Object[] and sub-types; one per primitive type).

      Since:
        2.2 Moved from earlier `Comparators` class

    - #### arrayToSet

          public static <T> java.util.HashSet<T> arrayToSet(T[] elements)

    - #### arrayToList

          public static <T> java.util.ArrayList<T> arrayToList(T[] elements)

    - #### setAndArray

          public static <T> java.util.HashSet<T> setAndArray(java.util.Set<T> set,
                                             T[] elements)

    - #### addToList

          public static <T> java.util.List<T> addToList(java.util.List<T> list,
                                        T element)

      Helper method for adding specified element to a List, but also considering case where the List may not have been yet constructed (that is, null is passed instead).
      Parameters:
        `list` - List to add to; may be null to indicate that a new List is to be constructed
        `element` - Element to add to list
      Returns:
        List in which element was added; either `list` (if it was not null), or a newly constructed List.

    - #### insertInList

          public static <T> T[] insertInList(T[] array,
                             T element)

      Helper method for constructing a new array that contains specified element followed by contents of the given array. No checking is done to see if element being inserted is duplicate.

    - #### insertInListNoDup

          public static <T> T[] insertInListNoDup(T[] array,
                                  T element)

      Helper method for constructing a new array that contains specified element followed by contents of the given array but never contains duplicates. If element already existed, one of two things happens: if the element was already the first one in array, array is returned as is; but if not, a new copy is created in which element has moved as the head.