Package org.skriptlang.skript.lang.entry
Class EntryContainer
java.lang.Object
org.skriptlang.skript.lang.entry.EntryContainer
An EntryContainer is a data container for obtaining the values of the entries of a
SectionNode
.-
Method Summary
Modifier and TypeMethodDescriptionA method for obtaining a non-null entry value with an unknown type.<E,
R extends E>
RA method for obtaining a non-null, typed entry value.@Nullable Object
getOptional
(String key, boolean useDefaultValue) A method for obtaining a nullable entry value with an unknown type.<E,
R extends E>
RgetOptional
(String key, Class<E> expectedType, boolean useDefaultValue) A method for obtaining a nullable, typed entry value.static EntryContainer
withoutValidator
(SectionNode source) Used for creating an EntryContainer when noEntryValidator
exists.
-
Method Details
-
withoutValidator
Used for creating an EntryContainer when noEntryValidator
exists.- Parameters:
source
- The SectionNode to create a container for.- Returns:
- An EntryContainer where all nodes will be
getUnhandledNodes()
.
-
getSource
- Returns:
- The SectionNode containing the entries associated with this EntryValidator.
-
getUnhandledNodes
- Returns:
- Any nodes unhandled by the
EntryValidator
. The validator must have a node testing predicate for this list to contain any values. The 'unhandled node' would represent any entry provided by the user that the validator is not explicitly aware of.
-
get
A method for obtaining a non-null, typed entry value. This method should ONLY be called if there is no way the entry could return null. In general, this means that the entry has a default value (and 'useDefaultValue' is true). This is because even though an entry may be required, parsing errors may occur that mean no value can be returned. It can also mean that the entry data is simple enough such that it will never return a null value.- Parameters:
key
- The key associated with the entry.expectedType
- The class representing the expected type of the entry's value.useDefaultValue
- Whether the default value should be used if parsing failed.- Returns:
- The entry's value.
- Throws:
RuntimeException
- If the entry's value is null, or if it is not of the expected type.
-
get
A method for obtaining a non-null entry value with an unknown type. This method should ONLY be called if there is no way the entry could return null. In general, this means that the entry has a default value (and 'useDefaultValue' is true). This is because even though an entry may be required, parsing errors may occur that mean no value can be returned. It can also mean that the entry data is simple enough such that it will never return a null value.- Parameters:
key
- The key associated with the entry.useDefaultValue
- Whether the default value should be used if parsing failed.- Returns:
- The entry's value.
- Throws:
RuntimeException
- If the entry's value is null.
-
getOptional
@Nullable public <E,R extends E> R getOptional(String key, Class<E> expectedType, boolean useDefaultValue) A method for obtaining a nullable, typed entry value.- Parameters:
key
- The key associated with the entry.expectedType
- The class representing the expected type of the entry's value.useDefaultValue
- Whether the default value should be used if parsing failed.- Returns:
- The entry's value. May be null if the entry is missing or a parsing error occurred.
- Throws:
RuntimeException
- If the entry's value is not of the expected type.
-
getOptional
A method for obtaining a nullable entry value with an unknown type.- Parameters:
key
- The key associated with the entry.useDefaultValue
- Whether the default value should be used if parsing failed.- Returns:
- The entry's value. May be null if the entry is missing or a parsing error occurred.
-