Class ValidationEvent

java.lang.Object
software.amazon.smithy.model.validation.ValidationEvent
All Implemented Interfaces:
Comparable<ValidationEvent>, ToNode, ToSmithyBuilder<ValidationEvent>

public final class ValidationEvent extends Object implements Comparable<ValidationEvent>, ToNode, ToSmithyBuilder<ValidationEvent>
A validation event created when validating a model.

Validation events are collection while assembling and validating a model. Events with a severity less than ERROR can be suppressed. All events contain a message, severity, and eventId.

  • Method Details

    • builder

      public static ValidationEvent.Builder builder()
    • fromSourceException

      public static ValidationEvent fromSourceException(SourceException exception)
      Creates a new ValidationEvent from a SourceException.
      Parameters:
      exception - Exception to use to create the event.
      Returns:
      Returns a created validation event with an ID of Model.
    • fromSourceException

      public static ValidationEvent fromSourceException(SourceException exception, String prefix)
      Creates a new ValidationEvent from a SourceException.
      Parameters:
      exception - Exception to use to create the event.
      prefix - Prefix string to add to the message.
      Returns:
      Returns a created validation event with an ID of Model.
    • fromSourceException

      public static ValidationEvent fromSourceException(SourceException exception, String prefix, ShapeId shapeId)
      Creates a new ValidationEvent from a SourceException.
      Parameters:
      exception - Exception to use to create the event.
      prefix - Prefix string to add to the message.
      shapeId - ShapeId to associate with the event.
      Returns:
      Returns a created validation event with an ID of Model.
    • compareTo

      public int compareTo(ValidationEvent other)
      Specified by:
      compareTo in interface Comparable<ValidationEvent>
    • toBuilder

      public ValidationEvent.Builder toBuilder()
      Description copied from interface: ToSmithyBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToSmithyBuilder<ValidationEvent>
      Returns:
      a builder for type T
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public Node toNode()
      Description copied from interface: ToNode
      Converts a value to a Node.
      Specified by:
      toNode in interface ToNode
      Returns:
      Returns the creates Node.
    • fromNode

      public static ValidationEvent fromNode(Node node)
    • getSourceLocation

      public SourceLocation getSourceLocation()
      Returns:
      The location at which the event occurred.
    • getMessage

      public String getMessage()
      Returns:
      The human-readable event message.
    • getSeverity

      public Severity getSeverity()
      Returns:
      The severity level of the event.
    • getEventId

      public String getEventId()
      Deprecated.
      Use the getId() method to match the node format.
      Returns the identifier of the validation event.

      The validation event identifier can be used to suppress events.

      Returns:
      Returns the event ID.
    • containsId

      public boolean containsId(String id)
      Tests if the event ID hierarchically contains the given ID.

      Event IDs that contain dots (.) are hierarchical. An event ID of "Foo.Bar" contains the ID "Foo" and "Foo.Bar". However, an event ID of "Foo" does not contain the ID "Foo.Bar" as "Foo.Bar" is more specific than "Foo". If an event ID exactly matches the given id, then it also contains the ID (for example, "Foo.Bar." contains "Foo.Bar.".

      Parameters:
      id - ID to test.
      Returns:
      Returns true if the event's event ID contains the given id.
    • getId

      public String getId()
      Returns the identifier of the validation event.

      The validation event identifier can be used to suppress events.

      Returns:
      Returns the event ID.
    • getShapeId

      public Optional<ShapeId> getShapeId()
      Returns:
      The shape ID that is associated with the event.
    • getSuppressionReason

      public Optional<String> getSuppressionReason()
      Get the reason that the event was suppressed.
      Returns:
      Returns the suppression reason if available.