类 ConfigValue<T,U>
java.lang.Object
cc.carm.lib.configuration.value.ValueManifest<T,U>
cc.carm.lib.configuration.value.ConfigValue<T,U>
- 直接已知子类:
CachedConfigValue
Represents a configurable value with type safety and null-handling capabilities.
This abstract class provides core functionalities for managing configuration values, including value retrieval with fallback defaults, null safety enforcement, and value persistence controls. It serves as the foundation for type-specific configuration implementations.
Functions:
- Type-safe value access through
get()andoptional() - Default value fallback via
getOrDefault() - Null-safety enforcement with
resolve()andgetNotNull() - Default value initialization through
setDefault() - Value comparison with
isDefault()
Persistence Behavior:
Value modifications viaset(Object) or setDefault() methods
do NOT automatically persist to configuration sources. Explicit calls to
ConfigurationHolder.save() are required for permanent storage.-
字段概要
从类继承的字段 cc.carm.lib.configuration.value.ValueManifest
defaultSupplier, holder, initializer, path, type, validator -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明abstract Tget()Gets the configured value (i.e., the value read from the source).Gets the non-null value of this configuration.Gets the configured value, or returns the default value if not present.booleanChecks if the loaded configuration value matches the default value.optional()Gets the value of this configuration as anOptional.resolve()Gets the non-null value of this configuration.voidsave()Try to save the configuration.abstract voidSets the value of this configuration.voidInitializes the default value for this configuration.voidsetDefault(boolean override) Sets the configuration value to its default.从类继承的方法 cc.carm.lib.configuration.value.ValueManifest
config, defaults, defaults, defaults, getData, hasDefaults, holder, holder, initialize, initialize, metadata, path, path, setData, throwing, throwing, type, validate, validator, validator, withValidated
-
构造器详细资料
-
ConfigValue
-
-
方法详细资料
-
get
Gets the configured value (i.e., the value read from the source).
If no default value was written during initialization, you can use thegetOrDefault()method to obtain the default value when this value is empty.- 返回:
- Configured value
-
getOrDefault
Gets the configured value, or returns the default value if not present.- 返回:
- Configured value or default value
-
resolve
Gets the non-null value of this configuration.- 返回:
- Non-null value
- 抛出:
NullPointerException- Thrown when the corresponding data is null
-
getNotNull
Gets the non-null value of this configuration.- 返回:
- Non-null value
- 抛出:
NullPointerException- Thrown when the corresponding data is null- 另请参阅:
-
optional
Gets the value of this configuration as anOptional.- 返回:
Optionalvalue
-
set
Sets the value of this configuration.
After setting, the configuration file will NOT be saved automatically. To save, callConfigurationHolder.save().- 参数:
value- The value to set
-
setDefault
public void setDefault()Initializes the default value for this configuration.
After setting, the configuration file will NOT be saved automatically. To save, callConfigurationHolder.save(). -
setDefault
public void setDefault(boolean override) Sets the configuration value to its default.
After setting, the configuration file will NOT be saved automatically. To save, callConfigurationHolder.save().- 参数:
override- Whether to overwrite existing configured value
-
isDefault
public boolean isDefault()Checks if the loaded configuration value matches the default value.- 返回:
- Whether the current value is the default value
-
save
Try to save the configuration.
To save multiple modifications, it is recommended to callConfigurationHolder.save()after all modifications are completed instead of this.- 抛出:
Exception- Thrown when an error occurs during saving
-