Record Class Diagnostic

java.lang.Object
java.lang.Record
fr.robie.machineengine.api.diagnostic.Diagnostic
Record Components:
severity - how serious it is
code - stable machine-readable code, e.g. machineengine:duplicate_key
message - human-readable explanation
source - the addon responsible, if known. Errors disable that addon's content.
subject - the entry concerned, if any
location - where it was defined (file, path), if known
context - extra key/value details for debugging

public record Diagnostic(@NotNull Severity severity, @NotNull net.kyori.adventure.key.Key code, @NotNull String message, @Nullable AddonId source, @Nullable net.kyori.adventure.key.Key subject, @Nullable String location, @NotNull Map<String,Object> context) extends Record
One validation finding (ARCHITECTURE.md ยง24).
  • Constructor Details

    • Diagnostic

      public Diagnostic(@NotNull @NotNull Severity severity, @NotNull @NotNull net.kyori.adventure.key.Key code, @NotNull @NotNull String message, @Nullable @Nullable AddonId source, @Nullable @Nullable net.kyori.adventure.key.Key subject, @Nullable @Nullable String location, @NotNull @NotNull Map<String,Object> context)
      Creates an instance of a Diagnostic record class.
      Parameters:
      severity - the value for the severity record component
      code - the value for the code record component
      message - the value for the message record component
      source - the value for the source record component
      subject - the value for the subject record component
      location - the value for the location record component
      context - the value for the context record component
  • Method Details

    • error

      @NotNull public static @NotNull Diagnostic.Builder error(@NotNull @NotNull net.kyori.adventure.key.Key code, @NotNull @NotNull String message)
    • warning

      @NotNull public static @NotNull Diagnostic.Builder warning(@NotNull @NotNull net.kyori.adventure.key.Key code, @NotNull @NotNull String message)
    • info

      @NotNull public static @NotNull Diagnostic.Builder info(@NotNull @NotNull net.kyori.adventure.key.Key code, @NotNull @NotNull String message)
    • isError

      public boolean isError()
    • withSource

      @NotNull public @NotNull Diagnostic withSource(@Nullable @Nullable AddonId addon)
      Returns:
      a copy attributed to addon
    • format

      @NotNull public @NotNull String format()
      One-line, log-friendly rendering.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • severity

      @NotNull public @NotNull Severity severity()
      Returns the value of the severity record component.
      Returns:
      the value of the severity record component
    • code

      @NotNull public @NotNull net.kyori.adventure.key.Key code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • message

      @NotNull public @NotNull String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • source

      @Nullable public @Nullable AddonId source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • subject

      @Nullable public @Nullable net.kyori.adventure.key.Key subject()
      Returns the value of the subject record component.
      Returns:
      the value of the subject record component
    • location

      @Nullable public @Nullable String location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component
    • context

      @NotNull public @NotNull Map<String,Object> context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component