Package com.google.common.collect
Class ImmutableRangeSet.Builder<C extends Comparable<?>>
- java.lang.Object
-
- com.google.common.collect.ImmutableRangeSet.Builder<C>
-
- Enclosing class:
- ImmutableRangeSet<C extends Comparable>
public static class ImmutableRangeSet.Builder<C extends Comparable<?>> extends Object
A builder for immutable range sets.- Since:
- 14.0
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableRangeSet.Builder<C>
add(Range<C> range)
Add the specified range to this builder.ImmutableRangeSet.Builder<C>
addAll(RangeSet<C> ranges)
Add all ranges from the specified range set to this builder.ImmutableRangeSet.Builder<C>
addAll(Iterable<Range<C>> ranges)
Add all of the specified ranges to this builder.ImmutableRangeSet<C>
build()
Returns anImmutableRangeSet
containing the ranges added to this builder.
-
-
-
Constructor Detail
-
Builder
public Builder()
-
-
Method Detail
-
add
@CanIgnoreReturnValue public ImmutableRangeSet.Builder<C> add(Range<C> range)
Add the specified range to this builder. Adjacent ranges are permitted and will be merged, but overlapping ranges will cause an exception whenbuild()
is called.- Throws:
IllegalArgumentException
- ifrange
is empty
-
addAll
@CanIgnoreReturnValue public ImmutableRangeSet.Builder<C> addAll(RangeSet<C> ranges)
Add all ranges from the specified range set to this builder. Adjacent ranges are permitted and will be merged, but overlapping ranges will cause an exception whenbuild()
is called.
-
addAll
@CanIgnoreReturnValue public ImmutableRangeSet.Builder<C> addAll(Iterable<Range<C>> ranges)
Add all of the specified ranges to this builder. Adjacent ranges are permitted and will be merged, but overlapping ranges will cause an exception whenbuild()
is called.- Throws:
IllegalArgumentException
- if any inserted ranges are empty- Since:
- 21.0
-
build
public ImmutableRangeSet<C> build()
Returns anImmutableRangeSet
containing the ranges added to this builder.- Throws:
IllegalArgumentException
- if any input ranges have nonempty overlap
-
-