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 aValidationResult
with only a validity flag.ValidationResult
(boolean valid, @Nullable String message) Constructs aValidationResult
with a validity flag and message.ValidationResult
(boolean valid, @Nullable String message, T data) Constructs aValidationResult
with a validity flag, message and result data.ValidationResult
(boolean valid, T data) Constructs aValidationResult
with a validity flag and result data. -
Method Summary
Modifier and TypeMethodDescriptiondata()
Returns the value of thedata
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@Nullable String
message()
Returns the value of themessage
record component.final String
toString()
Returns a string representation of this record class.boolean
valid()
Returns the value of thevalid
record component.
-
Constructor Details
-
ValidationResult
public ValidationResult(boolean valid) Constructs aValidationResult
with only a validity flag.- Parameters:
valid
- Whether the validation was successful.
-
ValidationResult
Constructs aValidationResult
with a validity flag and message.- Parameters:
valid
- Whether the validation was successful.message
- An optional message describing the result.
-
ValidationResult
Constructs aValidationResult
with a validity flag and result data.- Parameters:
valid
- Whether the validation was successful.data
- Optional data returned from the validation.
-
ValidationResult
Constructs aValidationResult
with 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 thevalid
record component.- Returns:
- the value of the
valid
record component
-
message
Returns the value of themessage
record component.- Returns:
- the value of the
message
record component
-
data
Returns the value of thedata
record component.- Returns:
- the value of the
data
record component
-