Class ValidationResult<T>
java.lang.Object
net.ixdarklord.coolcatcore.api.config.type.ValidationResult<T>
The outcome of checking a value: fine as is, corrected into a valid value (a number clamped into its range, say),
or rejected.
A file holding a correctable value loads the corrected one and is rewritten; the config screen and commands only accept values that are fine as they are.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ValidationResult<T> corrected(T corrected, net.minecraft.network.chat.Component message) The value was invalid;correctedis the closest valid one andmessagesays what was wrong.static <T> ValidationResult<T> error(net.minecraft.network.chat.Component message) booleanhasValue()Whether there's a usable value: fine or corrected.booleanbooleanisError()booleanisOk()<R> ValidationResult<R> Maps a usable value; a correction or an error carries over.Optional<net.minecraft.network.chat.Component> message()What was wrong; empty when the value is fine.static <T> ValidationResult<T> ok(T value) then(Function<? super T, ValidationResult<T>> next) Runs another check on the usable value.toString()value()The value, or the corrected value.
-
Method Details
-
ok
-
corrected
public static <T> ValidationResult<T> corrected(T corrected, net.minecraft.network.chat.Component message) The value was invalid;correctedis the closest valid one andmessagesays what was wrong. -
error
-
isOk
public boolean isOk() -
isCorrected
public boolean isCorrected() -
isError
public boolean isError() -
hasValue
public boolean hasValue()Whether there's a usable value: fine or corrected. -
value
The value, or the corrected value.- Throws:
IllegalStateException- for an error
-
message
What was wrong; empty when the value is fine. -
messageString
-
map
Maps a usable value; a correction or an error carries over. -
then
Runs another check on the usable value. An earlier correction survives a later check that passes; the first error wins. -
toString
-