Class OpenCollections.ListBuilder<T>

java.lang.Object
cloud.opencode.base.core.collect.OpenCollections.ListBuilder<T>
Type Parameters:
T - the element type / 元素类型
Enclosing class:
OpenCollections

public static final class OpenCollections.ListBuilder<T> extends Object
A builder for creating unmodifiable lists incrementally. 用于增量创建不可修改列表的构建器。
Since:
JDK 25, opencode-base-core V1.0.3
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • add

      public OpenCollections.ListBuilder<T> add(T element)
      Adds an element to this builder. 向此构建器添加元素。
      Parameters:
      element - the element to add (must not be null) / 要添加的元素(不可为 null)
      Returns:
      this builder / 此构建器
      Throws:
      NullPointerException - if element is null / 如果 element 为 null
    • addAll

      public OpenCollections.ListBuilder<T> addAll(Iterable<? extends T> iterable)
      Adds all elements from the iterable to this builder. 将可迭代对象中的所有元素添加到此构建器。
      Parameters:
      iterable - the elements to add (must not be null, no null elements) / 要添加的元素(不可为 null,元素不可为 null)
      Returns:
      this builder / 此构建器
      Throws:
      NullPointerException - if iterable or any element is null / 如果 iterable 或任何元素为 null
    • build

      public List<T> build()
      Builds and returns an unmodifiable list containing all added elements. 构建并返回包含所有已添加元素的不可修改列表。
      Returns:
      an unmodifiable list / 不可修改列表