Class ImmutableRangeSet.Builder<C extends java.lang.Comparable<?>>

  • Enclosing class:
    ImmutableRangeSet<C extends java.lang.Comparable>

    public static class ImmutableRangeSet.Builder<C extends java.lang.Comparable<?>>
    extends java.lang.Object
    A builder for immutable range sets.
    Since:
    14.0
    • Field Detail

      • ranges

        private final java.util.List<Range<C extends java.lang.Comparable<?>>> ranges
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • add

        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 when build() is called.
        Throws:
        java.lang.IllegalArgumentException - if range is empty
      • addAll

        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 when build() is called.
      • addAll

        public ImmutableRangeSet.Builder<C> addAll​(java.lang.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 when build() is called.
        Throws:
        java.lang.IllegalArgumentException - if any inserted ranges are empty
        Since:
        21.0
      • build

        public ImmutableRangeSet<C> build()
        Returns an ImmutableRangeSet containing the ranges added to this builder.
        Throws:
        java.lang.IllegalArgumentException - if any input ranges have nonempty overlap