Class UnexpectedElementException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.github.zafarkhaja.semver.util.UnexpectedElementException
All Implemented Interfaces:
Serializable

public class UnexpectedElementException extends RuntimeException
Thrown when attempting to consume a stream element of unexpected types.
Since:
0.7.0
See Also:
  • Field Details

    • unexpected

      private final Object unexpected
      The unexpected element in the stream.
    • position

      private final int position
      The position of the unexpected element in the stream.
    • expected

      private final Stream.ElementType<?>[] expected
      The array of the expected element types.
  • Constructor Details

    • UnexpectedElementException

      UnexpectedElementException(Object element, int position, Stream.ElementType<?>... expected)
      Constructs a UnexpectedElementException instance with the unexpected element and the expected types.
      Parameters:
      element - the unexpected element in the stream
      position - the position of the unexpected element
      expected - an array of the expected element types
  • Method Details

    • getUnexpectedElement

      public Object getUnexpectedElement()
      Gets the unexpected element.
      Returns:
      the unexpected element
    • getPosition

      public int getPosition()
      Gets the position of the unexpected element.
      Returns:
      the position of the unexpected element
    • getExpectedElementTypes

      public Stream.ElementType<?>[] getExpectedElementTypes()
      Gets the expected element types.
      Returns:
      an array of expected element types
    • toString

      public String toString()
      Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.
      Overrides:
      toString in class Throwable
      Returns:
      the string representation of this exception