Interface PropertyHandler<Type>
- Type Parameters:
Type
- The type of object this property can be applied to.
- All Known Subinterfaces:
PropertyHandler.ConditionPropertyHandler<Type>
,PropertyHandler.ContainsHandler<Container,
,Element> PropertyHandler.ExpressionPropertyHandler<Type,
,ReturnType> PropertyHandler.TypedValuePropertyHandler<Type,
ValueType>
- All Known Implementing Classes:
PlayerClassInfo.PlayerDisplayNameHandler
@Experimental
public interface PropertyHandler<Type>
A handler for a specific property. Any method of resolving or changing the property should be done here.
A handler can be nearly anything and do nearly anything. Some examples are provided in the sub-interfaces.
If a handler needs to store state, it should override
If a handler needs to store state, it should override
newInstance()
to return a new instance of itself.
Each new instance will be initialized with init(Expression, ParserInstance)
before use, so state can be
set up there if it depends on the parser instance or parent expression.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A handler for a simple property condition.static interface
A handler that can check if a container contains a specific element.static interface
A handler that can get and optionally change a property value.static interface
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
init
(Expression<?> parentExpression, ParserInstance parser) Initializes this handler with the given parser instance.default PropertyHandler
<Type> Creates a new instance of this handler.
-
Method Details
-
newInstance
Creates a new instance of this handler. If a handler does not need to store state, it can simply returnthis
. If a handler needs to store state, it **MUST** return a new instance of itself. Seeinvalid reference
ScriptClassInfo.ScriptNameHandler
- Returns:
- A new instance of this handler, or
this
if no state is stored.
-
init
Initializes this handler with the given parser instance. This method is called once afternewInstance()
. If the handler does not need any initialization, it can simply returntrue
.
It is safe to print warnings or errors from this method.- Parameters:
parentExpression
- The expression that is using this handler. Can be used to get context about the property usage.parser
- The parser instance that will use this handler.- Returns:
true
if the handler was initialized successfully,false
otherwise.
-