Class ImmutableSpan

  • All Implemented Interfaces:
    Span, Serializable

    @ParametersAreNonnullByDefault
    @Generated("org.immutables.processor.ProxyProcessor")
    @Immutable
    @CheckReturnValue
    public final class ImmutableSpan
    extends Object
    implements Span
    Immutable implementation of Span.

    Use the builder to create immutable instances: ImmutableSpan.builder(). Use the static factory method to create immutable instances: ImmutableSpan.of().

    See Also:
    Serialized Form
    • Method Detail

      • getStartIndex

        public int getStartIndex()
        Specified by:
        getStartIndex in interface Span
        Returns:
        The value of the startIndex attribute
      • getStopIndex

        public int getStopIndex()
        Specified by:
        getStopIndex in interface Span
        Returns:
        The value of the stopIndex attribute
      • withStartIndex

        public final ImmutableSpan withStartIndex​(int value)
        Copy the current immutable object by setting a value for the startIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for startIndex
        Returns:
        A modified copy of the this object
      • withStopIndex

        public final ImmutableSpan withStopIndex​(int value)
        Copy the current immutable object by setting a value for the stopIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for stopIndex
        Returns:
        A modified copy of the this object
      • equals

        public boolean equals​(@Nullable
                              Object another)
        This instance is equal to all instances of ImmutableSpan that have equal attribute values.
        Overrides:
        equals in class Object
        Returns:
        true if this is equal to another instance
      • hashCode

        public int hashCode()
        Computes a hash code from attributes: startIndex, stopIndex.
        Overrides:
        hashCode in class Object
        Returns:
        hashCode value
      • toString

        public String toString()
        Prints the immutable value Span with attribute values.
        Overrides:
        toString in class Object
        Returns:
        A string representation of the value
      • of

        public static ImmutableSpan of​(int startIndex,
                                       int stopIndex)
        Construct a new immutable Span instance.
        Parameters:
        startIndex - The value for the startIndex attribute
        stopIndex - The value for the stopIndex attribute
        Returns:
        An immutable Span instance
      • copyOf

        public static ImmutableSpan copyOf​(Span instance)
        Creates an immutable copy of a Span value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
        Parameters:
        instance - The instance to copy
        Returns:
        A copied immutable Span instance