Class Length

java.lang.Object
org.midheaven.collections.Length
Direct Known Subclasses:
Length.Finite, Length.Infinite, Length.Unknown

public abstract sealed class Length extends Object permits Length.Finite, Length.Infinite, Length.Unknown
Represents the Length of an Enumerator. It can be infinite, finite or unknown
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
    static final class 
     
    static final class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Length
    finite(Int length)
    Creates a finite Length with the given length
    abstract Length
    min(Length other)
    Returns a new Length that is the minimum between this and the given Length min(finite(x), finite(y)) -> finite(x <= y ? x : y) min(finite(x), infinite) -> finite(x) min(finite(x), unknown) -> unknown min(infinite, unknown) -> unknown
    abstract Length
    minus(Length other)
    Subtracts the given value from this value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Length

      public Length()
  • Method Details

    • finite

      public static Length finite(Int length)
      Creates a finite Length with the given length
      Parameters:
      length - the length value
      Returns:
    • min

      public abstract Length min(Length other)
      Returns a new Length that is the minimum between this and the given Length min(finite(x), finite(y)) -> finite(x <= y ? x : y) min(finite(x), infinite) -> finite(x) min(finite(x), unknown) -> unknown min(infinite, unknown) -> unknown
      Parameters:
      other - the other value
      Returns:
      the minimum Length
    • minus

      public abstract Length minus(Length other)
      Subtracts the given value from this value. finite(x) - finite(y) -> x - y finite(x) - infinite -> infinite infinite - finite(x) -> infinite finite(x) - unknown -> unknown unknown - finite(x) -> unknown infinite - infinite -> infinite infinite - unknown -> infinite unknown - infinite -> unknown unknown - unknown -> unknown
      Parameters:
      other - the value to subtract
      Returns:
      this - other