Package org.apache.juneau.internal
Class SetBuilder<E>
java.lang.Object
org.apache.juneau.internal.SetBuilder<E>
- Type Parameters:
E
- Element type.
Builder for sets.
See Also:
-
Constructor Summary
ConstructorDescriptionSetBuilder
(Class<E> elementType, Type... elementTypeArgs) Constructor.SetBuilder
(Set<E> addTo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdds a single value to this set.Adds multiple values to this set.addAll
(Collection<E> value) Appends the contents of the specified collection into this set.Adds arbitrary values to this set.Adds a value to this set if the specified flag is true.Adds entries to this set via JSON array strings.build()
Builds the set.copy()
Forces the existing set to be copied instead of appended to.sorted()
Converts the set into aSortedSet
.sorted
(Comparator<E> comparator) Converts the set into aSortedSet
using the specified comparator.sparse()
When specified, thebuild()
method will returnnull if the set is empty.When specified,build()
will return an unmodifiable set.
-
Constructor Details
-
SetBuilder
Constructor.- Parameters:
elementType
- The element type.elementTypeArgs
- The element type generic arguments if there are any.
-
SetBuilder
Constructor.- Parameters:
addTo
- The set to add to.
-
-
Method Details
-
build
Builds the set.- Returns:
- A set conforming to the settings on this builder.
-
sparse
When specified, thebuild()
method will returnnull if the set is empty.Otherwise
build()
will never returnnull .- Returns:
- This object.
-
unmodifiable
When specified,build()
will return an unmodifiable set.- Returns:
- This object.
-
copy
Forces the existing set to be copied instead of appended to.- Returns:
- This object.
-
sorted
Converts the set into aSortedSet
.- Returns:
- This object.
-
sorted
Converts the set into aSortedSet
using the specified comparator.- Parameters:
comparator
- The comparator to use for sorting.- Returns:
- This object.
-
addAll
Appends the contents of the specified collection into this set.This is a no-op if the value is
null .- Parameters:
value
- The collection to add to this set.- Returns:
- This object.
-
add
Adds a single value to this set.- Parameters:
value
- The value to add to this set.- Returns:
- This object.
-
add
Adds multiple values to this set.- Parameters:
values
- The values to add to this set.- Returns:
- This object.
-
addJson
Adds entries to this set via JSON array strings.- Parameters:
values
- The JSON array strings to parse and add to this set.- Returns:
- This object.
-
addAny
Adds arbitrary values to this set.Objects can be any of the following:
- The same type or convertible to the element type of this set.
- Collections or arrays of anything on this set.
- JSON array strings parsed and convertible to the element type of this set.
- Parameters:
values
- The values to add.- Returns:
- This object.
-
addIf
Adds a value to this set if the specified flag is true.- Parameters:
flag
- The flag.value
- The value.- Returns:
- This object.
-