Package ch.njol.skript.lang.util.common
Interface AnyValued<Type>
- All Superinterfaces:
AnyProvider
- All Known Implementing Classes:
EntryNode
A provider for anything with a value.
Anything implementing this (or convertible to this) can be used by the
ExprValue
property expression.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
changeValue
(Type value) The behaviour for changing this thing's value, if possible.default void
changeValueSafely
(Object value) This method can be overridden to filter out bad values (e.g.default <Converted>
ConvertedconvertedValue
(ClassInfo<Converted> expected) default void
A default implementation of 'resetting' the value (setting it to null).default boolean
This is called beforechangeValue(Object)
.@UnknownNullability Type
value()
-
Method Details
-
value
@UnknownNullability Type value()- Returns:
- This thing's value
-
convertedValue
-
supportsValueChange
default boolean supportsValueChange()This is called beforechangeValue(Object)
. If the result is false, setting the value will never be attempted.- Returns:
- Whether this supports being set
-
changeValue
The behaviour for changing this thing's value, if possible. If not possible, thensupportsValueChange()
should return false and this may throw an error.- Parameters:
value
- The new value- Throws:
UnsupportedOperationException
- If this is impossible
-
valueType
- Returns:
- The type of values this accepts (or provides)
-
resetValue
A default implementation of 'resetting' the value (setting it to null). Implementations should override this if different behaviour is required.- Throws:
UnsupportedOperationException
- If changing is not supported
-
changeValueSafely
This method can be overridden to filter out bad values (e.g. null, objects of the wrong type, etc.) and make surechangeValue(Object)
is not called with a bad parameter.- Parameters:
value
- The (unchecked) new value- Throws:
UnsupportedOperationException
-