Class ImmutableCollection.Builder<E>

    • Method Detail

      • add

        @CanIgnoreReturnValue
        public ImmutableCollection.Builder<Eadd​(E... elements)
        Adds each element of elements to the ImmutableCollection being built.

        Note that each builder class overrides this method in order to covariantly return its own type.

        Parameters:
        elements - the elements to add
        Returns:
        this Builder instance
        Throws:
        NullPointerException - if elements is null or contains a null element
      • addAll

        @CanIgnoreReturnValue
        public ImmutableCollection.Builder<EaddAll​(Iterable<? extends E> elements)
        Adds each element of elements to the ImmutableCollection being built.

        Note that each builder class overrides this method in order to covariantly return its own type.

        Parameters:
        elements - the elements to add
        Returns:
        this Builder instance
        Throws:
        NullPointerException - if elements is null or contains a null element
      • addAll

        @CanIgnoreReturnValue
        public ImmutableCollection.Builder<EaddAll​(Iterator<? extends E> elements)
        Adds each element of elements to the ImmutableCollection being built.

        Note that each builder class overrides this method in order to covariantly return its own type.

        Parameters:
        elements - the elements to add
        Returns:
        this Builder instance
        Throws:
        NullPointerException - if elements is null or contains a null element
      • build

        public abstract ImmutableCollection<Ebuild()
        Returns a newly-created ImmutableCollection of the appropriate type, containing the elements provided to this builder.

        Note that each builder class covariantly returns the appropriate type of ImmutableCollection from this method.