Record Class LoadIssue

java.lang.Object
java.lang.Record
de.bsommerfeld.jshepherd.core.LoadIssue
Record Components:
key - the configuration key that failed to apply
rawValue - the raw value found in the file (may be null)
targetType - the Java type of the field the value was meant for
message - a human-readable description of what went wrong

public record LoadIssue(String key, Object rawValue, Class<?> targetType, String message) extends Record
Describes a single value that could not be applied during a load or reload — for example a string that does not parse into a numeric field, or an unknown enum constant.

When such an issue occurs, the affected field keeps its current (default) value, a warning is logged, and the issue is recorded on the configuration POJO. Retrieve the issues via ConfigurablePojo.getLastLoadIssues() — typically inside a @PostInject method to fail fast:


 @PostInject
 private void validate() {
     if (!getLastLoadIssues().isEmpty()) {
         throw new IllegalStateException("Invalid config: " + getLastLoadIssues());
     }
 }
 
  • Constructor Details

    • LoadIssue

      public LoadIssue(String key, Object rawValue, Class<?> targetType, String message)
      Creates an instance of a LoadIssue record class.
      Parameters:
      key - the value for the key record component
      rawValue - the value for the rawValue record component
      targetType - the value for the targetType record component
      message - the value for the message record component
  • Method Details

    • toString

      public 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.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • rawValue

      public Object rawValue()
      Returns the value of the rawValue record component.
      Returns:
      the value of the rawValue record component
    • targetType

      public Class<?> targetType()
      Returns the value of the targetType record component.
      Returns:
      the value of the targetType record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component