Class RangeExtent

java.lang.Object
net.hydromatic.morel.type.RangeExtent

public class RangeExtent extends Object
A type and a range set.
  • Field Details

    • rangeSetMap

      public final Map<String,com.google.common.collect.ImmutableRangeSet> rangeSetMap
      Map from path to range set.

      The path designates the item within the type.

      For example, consider the type int option list.

      • "/" relates to the int option list
      • "/0/" relates to each int option within the list
      • "/0/SOME/" relates to each int within a "SOME" element of the list
      • "/0/NONE/" relates to each "NONE" element of the list

      Using a map ["/O/SOME/" "[0, 3], [6]"] we can generate SOME 0, SOME 1, SOME 2, SOME 3, SOME 6, NONE

    • type

      public final Type type
    • iterable

      public final @Nullable Iterable iterable
  • Constructor Details

    • RangeExtent

      public RangeExtent(TypeSystem typeSystem, Type type, Map<String,com.google.common.collect.ImmutableRangeSet> rangeSetMap)
      Creates a RangeExtent.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isUnbounded

      public boolean isUnbounded()
      Whether this extent returns all, or an unbounded number of, the values of its type.

      Examples: "(-inf,+inf)" (true), "(-inf,0]" (x ≤ 0), "{(-inf,3),(10,+inf)}" (x < 3 or x > 10) are unbounded; "{}" (false), "{3, 10}" (x in [3, 10]), "(3, 10)" (x ≥ 3 andalso x ≤ 10) are bounded.

    • toList

      private <E extends Comparable<E>> Iterable<E> toList(Type type, TypeSystem typeSystem)
      Derives the collection of values in the range, or returns empty if the range is infinite.
    • populate

      private <E extends Comparable<E>> boolean populate(TypeSystem typeSystem, Type type, String path, Map<String,com.google.common.collect.ImmutableRangeSet> rangeSetMap, Consumer<E> consumer)
      Populates a list (or other consumer) with all values of this type. Returns false if this type is not finite and the range is open above or below.