Class PropertyExpression<O,T>
java.lang.Object
io.github.syst3ms.skriptparser.lang.properties.PropertyExpression<O,T>
- Type Parameters:
O- The type of the owner of this expression.T- The returned type of this expression.
- All Implemented Interfaces:
Expression<T>, SyntaxElement
- Direct Known Subclasses:
ExprAmount, ExprColorValues, ExprDateTimestamp, ExprLength
A base class for expressions that contain general properties.
In English, one can express properties in many different ways:
- Mwexim's book
- the book of Mwexim
init(Expression[], int, ParseContext)
and getValues(TriggerContext). Their default functionality is specified below.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]composePatterns(String property, String owner) getOwner()getProperty(O owner) For each owner, this method will be ran individually to convert it to this particular property.T[]getValues(TriggerContext ctx) A simple default method that will applygetProperty(Object)on theownerof this property.booleaninit(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) This defaultinit()implementation automatically properly sets the owner of this property, which can be accessed usinggetOwner().booleanYou can express possession in two different ways: genitive: Mwexim's book regular: book of Mwexim One may use this method to check if the pattern used is in the genitive form.booleanisSingle()voidsetOwner(Expression<O> owner) toString(TriggerContext ctx, boolean debug) protected StringtoString(TriggerContext ctx, boolean debug, String property) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Expression
acceptsChange, acceptsChange, acceptsChange, change, check, check, convertExpression, getArray, getReturnType, getSingle, getSource, isAndList, isLoopOf, iterator, setAndList, stream
-
Field Details
-
PROPERTY_IDENTIFIER
- See Also:
-
-
Constructor Details
-
PropertyExpression
public PropertyExpression()
-
-
Method Details
-
init
This defaultinit()implementation automatically properly sets the owner of this property, which can be accessed usinggetOwner(). If this implementation is overridden for one reason or another, it must callsetOwner(Expression)properly.- Specified by:
initin interfaceSyntaxElement- Parameters:
expressions- an array of expressions representing all the expressions that are being passed to this syntax element.matchedPattern- the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registrationparseContext- an object containing additional information about the parsing of this syntax element, like regex matches and parse marks- Returns:
- whether the initialization was successful or not.
- See Also:
-
getValues
A simple default method that will applygetProperty(Object)on theownerof this property.- Specified by:
getValuesin interfaceExpression<O>- Parameters:
ctx- the event- Returns:
- the values of this property after applying the
getProperty(Object)function on the owner. - See Also:
-
getProperty
-
isSingle
public boolean isSingle()- Specified by:
isSinglein interfaceExpression<O>- Returns:
- whether this expression returns a single value. By default, this is defined on registration, but it can be overridden.
-
toString
- Specified by:
toStringin interfaceSyntaxElement- Parameters:
ctx- the eventdebug- whether to show additional information or not- Returns:
- a
Stringthat should aim to resemble what is written in the script as closely as possible
-
toString
-
getOwner
-
setOwner
-
isGenitive
public boolean isGenitive()You can express possession in two different ways:- genitive: Mwexim's book
- regular: book of Mwexim
- Returns:
- whether the pattern is in the genitive form or not.
-
composePatterns
-