Class ImmutableNullableList.Builder<E>

  • Type Parameters:
    E - element type
    Enclosing class:
    ImmutableNullableList<E>

    public static final class ImmutableNullableList.Builder<E>
    extends java.lang.Object
    A builder for creating immutable nullable list instances.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<E> contents  
    • Constructor Summary

      Constructors 
      Constructor Description
      Builder()
      Creates a new builder.
    • Field Detail

      • contents

        private final java.util.List<E> contents
    • Constructor Detail

    • Method Detail

      • add

        public ImmutableNullableList.Builder<E> add​(E element)
        Adds element to the ImmutableNullableList.
        Parameters:
        element - the element to add
        Returns:
        this Builder object
      • addAll

        public ImmutableNullableList.Builder<E> addAll​(java.lang.Iterable<? extends E> elements)
        Adds each element of elements to the ImmutableNullableList.
        Parameters:
        elements - the Iterable to add to the ImmutableNullableList
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null
      • add

        public ImmutableNullableList.Builder<E> add​(E... elements)
        Adds each element of elements to the ImmutableNullableList.
        Parameters:
        elements - the elements to add to the ImmutableNullableList
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null
      • addAll

        public ImmutableNullableList.Builder<E> addAll​(java.util.Iterator<? extends E> elements)
        Adds each element of elements to the ImmutableNullableList.
        Parameters:
        elements - the elements to add to the ImmutableNullableList
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null
      • build

        public java.util.List<E> build()
        Returns a newly-created ImmutableNullableList based on the contents of the Builder.