Package org.apache.juneau.internal
Class ArrayBuilder<E>
java.lang.Object
org.apache.juneau.internal.ArrayBuilder<E>
- Type Parameters:
E- The array element type.
Builder for arrays.
Designed to create arrays without array copying.
Initial capacity cannot be exceeded without throwing a ArrayIndexOutOfBoundsException.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends to this array if the specified value is not null.The predicate to use to filter values added to this builder.static <E> ArrayBuilder<E>Static creator.E[]Returns the populated array.size(int value) Sets the expected size for this array.
-
Constructor Details
-
ArrayBuilder
Constructor.- Parameters:
elementType- The element type.
-
-
Method Details
-
of
Static creator.- Type Parameters:
E- The element type.- Parameters:
elementType- The element type.- Returns:
- A new builder object.
-
size
Sets the expected size for this array.- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
filter
The predicate to use to filter values added to this builder.- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
add
Appends to this array if the specified value is not null.- Parameters:
t- The element to add.- Returns:
- This object.
- Throws:
ArrayIndexOutOfBoundsException- if size is exceeded.
-
orElse
Returns the populated array.- Parameters:
def- The default value if no values were added to this builder.- Returns:
- A new array containing the added entries.
-