Package ch.njol.skript.util
Record Class ValidationResult<T>
java.lang.Object
java.lang.Record
ch.njol.skript.util.ValidationResult<T>
- Type Parameters:
T- The type of data returned from a successful validation.- Record Components:
valid- Whether the validation was successful.message- An optional message describing the result.data- Optional data returned from the validation.
Represents the result of a validation check.
This record stores whether a check was valid, an optional message explaining the result (i.e., an error or warning message), and optional data returned from the check if it successfully passed.
-
Constructor Summary
ConstructorsConstructorDescriptionValidationResult(boolean valid) Constructs aValidationResultwith only a validity flag.ValidationResult(boolean valid, @Nullable String message) Constructs aValidationResultwith a validity flag and message.ValidationResult(boolean valid, @Nullable String message, T data) Constructs aValidationResultwith a validity flag, message and result data.ValidationResult(boolean valid, T data) Constructs aValidationResultwith a validity flag and result data. -
Method Summary
Modifier and TypeMethodDescriptiondata()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable Stringmessage()Returns the value of themessagerecord component.final StringtoString()Returns a string representation of this record class.booleanvalid()Returns the value of thevalidrecord component.
-
Constructor Details
-
ValidationResult
public ValidationResult(boolean valid) Constructs aValidationResultwith only a validity flag.- Parameters:
valid- Whether the validation was successful.
-
ValidationResult
Constructs aValidationResultwith a validity flag and message.- Parameters:
valid- Whether the validation was successful.message- An optional message describing the result.
-
ValidationResult
Constructs aValidationResultwith a validity flag and result data.- Parameters:
valid- Whether the validation was successful.data- Optional data returned from the validation.
-
ValidationResult
Constructs aValidationResultwith a validity flag, message and result data.- Parameters:
valid- Whether the validation was successful.message- An optional message describing the result.data- Optional data returned from the validation.
-
-
Method Details
-
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. -
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. -
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
valid
public boolean valid()Returns the value of thevalidrecord component.- Returns:
- the value of the
validrecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
data
Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-