Class ImmutableCollection.Builder

  • Enclosing class:
    ImmutableCollection

    @NotThreadSafe
    public static final class ImmutableCollection.Builder
    extends Object
    Builds instances of type ImmutableCollection. Initialize attributes and then invoke the build() method to create an immutable instance.

    Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

    • Method Detail

      • from

        public final ImmutableCollection.Builder from​(Collection instance)
        Fill a builder with attribute values from the provided Collection instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.
        Parameters:
        instance - The instance from which to copy values
        Returns:
        this builder for use in a chained invocation
      • id

        public final ImmutableCollection.Builder id​(@Nullable
                                                    String id)
        Initializes the value for the id attribute.
        Parameters:
        id - The value for id (can be null)
        Returns:
        this builder for use in a chained invocation
      • teamID

        public final ImmutableCollection.Builder teamID​(@Nullable
                                                        String teamID)
        Initializes the value for the teamID attribute.
        Parameters:
        teamID - The value for teamID (can be null)
        Returns:
        this builder for use in a chained invocation
      • putTags

        public final ImmutableCollection.Builder putTags​(String key,
                                                         String value)
        Put one entry to the tags map.
        Parameters:
        key - The key in the tags map
        value - The associated value in the tags map
        Returns:
        this builder for use in a chained invocation
      • putTags

        public final ImmutableCollection.Builder putTags​(Map.Entry<String,​? extends String> entry)
        Put one entry to the tags map. Nulls are not permitted
        Parameters:
        entry - The key and value entry
        Returns:
        this builder for use in a chained invocation
      • tags

        public final ImmutableCollection.Builder tags​(@Nullable
                                                      Map<String,​? extends String> tags)
        Sets or replaces all mappings from the specified map as entries for the tags map. Nulls are not permitted as keys or values, but parameter itself can be null
        Parameters:
        tags - The entries that will be added to the tags map
        Returns:
        this builder for use in a chained invocation
      • putAllTags

        public final ImmutableCollection.Builder putAllTags​(Map<String,​? extends String> tags)
        Put all mappings from the specified map as entries to tags map. Nulls are not permitted
        Parameters:
        tags - The entries that will be added to the tags map
        Returns:
        this builder for use in a chained invocation