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 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:
  • Method Details

    • newInstance

      default PropertyHandler<Type> newInstance()
      Creates a new instance of this handler. If a handler does not need to store state, it can simply return this. If a handler needs to store state, it **MUST** return a new instance of itself. See
      invalid reference
      ScriptClassInfo.ScriptNameHandler
      for an example of a stateful handler.
      Returns:
      A new instance of this handler, or this if no state is stored.
    • init

      default boolean init(Expression<?> parentExpression, ParserInstance parser)
      Initializes this handler with the given parser instance. This method is called once after newInstance(). If the handler does not need any initialization, it can simply return true.
      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.