Class ConfigReference
java.lang.Object
tech.guilhermekaua.spigotboot.config.reference.ConfigReference
Immutable representation of a parsed config reference token.
Reference syntax supports:
${configName}- single config root${configName:path.to.value}- single config with path${folderConfigName.itemId}- folder config item root${folderConfigName.itemId:path.to.value}- folder config item with path
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ConfigReferencefolderConfigItem(@NotNull String rawToken, @NotNull String folderConfigName, @NotNull String itemId, @Nullable String path) Creates a reference to a folder config item.@NotNull StringGets the config name for single config references.@NotNull StringGets the folder config name for folder config item references.@Nullable StringGets the item ID for folder config item references.@NotNull ReferenceTargetKindgetKind()Gets the kind of reference target.@Nullable StringgetPath()Gets the path within the target config/item.@NotNull StringGets the original raw token string (e.g., "${items:items.custom_exp_bottle}").@NotNull StringGets the target name.booleanChecks if this reference targets a folder config item.booleanChecks if this reference targets the root of the config/item.booleanChecks if this reference targets a single config.static @NotNull ConfigReferencesingleConfig(@NotNull String rawToken, @NotNull String configName, @Nullable String path) Creates a reference to a single config.
-
Method Details
-
singleConfig
@NotNull public static @NotNull ConfigReference singleConfig(@NotNull @NotNull String rawToken, @NotNull @NotNull String configName, @Nullable @Nullable String path) Creates a reference to a single config.- Parameters:
rawToken- the original token string (e.g., "${configName:path}")configName- the config namepath- the path within the config, or null for root- Returns:
- the config reference
-
folderConfigItem
@NotNull public static @NotNull ConfigReference folderConfigItem(@NotNull @NotNull String rawToken, @NotNull @NotNull String folderConfigName, @NotNull @NotNull String itemId, @Nullable @Nullable String path) Creates a reference to a folder config item.- Parameters:
rawToken- the original token stringfolderConfigName- the folder config nameitemId- the item ID within the folder configpath- the path within the item, or null for root- Returns:
- the config reference
-
getRawToken
Gets the original raw token string (e.g., "${items:items.custom_exp_bottle}").- Returns:
- the raw token
-
getKind
Gets the kind of reference target.- Returns:
- the target kind
-
getTargetName
Gets the target name.For
ReferenceTargetKind.SINGLE_CONFIG, this is the config name. ForReferenceTargetKind.FOLDER_CONFIG_ITEM, this is the folder config name.- Returns:
- the target name
-
getConfigName
Gets the config name for single config references.- Returns:
- the config name
- Throws:
IllegalStateException- if this is not a single config reference
-
getFolderConfigName
Gets the folder config name for folder config item references.- Returns:
- the folder config name
- Throws:
IllegalStateException- if this is not a folder config item reference
-
getItemId
Gets the item ID for folder config item references.- Returns:
- the item ID, or null if this is a single config reference
-
getPath
Gets the path within the target config/item.- Returns:
- the path, or null if referencing the root
-
isRootReference
public boolean isRootReference()Checks if this reference targets the root of the config/item.- Returns:
- true if no path is specified
-
isSingleConfig
public boolean isSingleConfig()Checks if this reference targets a single config.- Returns:
- true if single config reference
-
isFolderConfigItem
public boolean isFolderConfigItem()Checks if this reference targets a folder config item.- Returns:
- true if folder config item reference
-