Class ValidationEvent
- java.lang.Object
-
- software.amazon.smithy.model.validation.ValidationEvent
-
- All Implemented Interfaces:
java.lang.Comparable<ValidationEvent>
,FromSourceLocation
,ToNode
,ToSmithyBuilder<ValidationEvent>
public final class ValidationEvent extends java.lang.Object implements FromSourceLocation, java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ValidationEvent.Builder
Builds ValidationEvent values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ValidationEvent.Builder
builder()
int
compareTo(ValidationEvent other)
boolean
containsId(java.lang.String id)
Tests if the event ID hierarchically contains the given ID.boolean
equals(java.lang.Object o)
static ValidationEvent
fromNode(Node node)
static ValidationEvent
fromSourceException(SourceException exception)
Creates a new ValidationEvent from aSourceException
.static ValidationEvent
fromSourceException(SourceException exception, java.lang.String prefix)
Creates a new ValidationEvent from aSourceException
.static ValidationEvent
fromSourceException(SourceException exception, java.lang.String prefix, ShapeId shapeId)
Creates a new ValidationEvent from aSourceException
.java.lang.String
getEventId()
Deprecated.Use thegetId()
method to match the node format.java.util.Optional<java.lang.String>
getHint()
Get an optional hint that adds more detail about how to fix a specific issue.java.lang.String
getId()
Returns the identifier of the validation event.java.lang.String
getMessage()
Severity
getSeverity()
java.util.Optional<ShapeId>
getShapeId()
SourceLocation
getSourceLocation()
Gets the source location of a value.java.util.Optional<java.lang.String>
getSuppressionReason()
Get the reason that the event was suppressed.int
hashCode()
ValidationEvent.Builder
toBuilder()
Take this object and create a builder that contains all of the current property values of this object.Node
toNode()
Converts a value to aNode
.java.lang.String
toString()
-
-
-
Method Detail
-
builder
public static ValidationEvent.Builder builder()
-
fromSourceException
public static ValidationEvent fromSourceException(SourceException exception)
Creates a new ValidationEvent from aSourceException
.- 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, java.lang.String prefix)
Creates a new ValidationEvent from aSourceException
.- 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, java.lang.String prefix, ShapeId shapeId)
Creates a new ValidationEvent from aSourceException
.- 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 interfacejava.lang.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 interfaceToSmithyBuilder<ValidationEvent>
- Returns:
- a builder for type T
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
fromNode
public static ValidationEvent fromNode(Node node)
-
getSourceLocation
public SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- The location at which the event occurred.
-
getMessage
public java.lang.String getMessage()
- Returns:
- The human-readable event message.
-
getSeverity
public Severity getSeverity()
- Returns:
- The severity level of the event.
-
getEventId
public java.lang.String getEventId()
Deprecated.Use thegetId()
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(java.lang.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 givenid
, 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 java.lang.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 java.util.Optional<ShapeId> getShapeId()
- Returns:
- The shape ID that is associated with the event.
-
getSuppressionReason
public java.util.Optional<java.lang.String> getSuppressionReason()
Get the reason that the event was suppressed.- Returns:
- Returns the suppression reason if available.
-
getHint
public java.util.Optional<java.lang.String> getHint()
Get an optional hint that adds more detail about how to fix a specific issue.- Returns:
- Returns the hint if available.
-
-