Package de.eldoria.eldoutilities.config
Record Class ConfigKey<T>
java.lang.Object
java.lang.Record
de.eldoria.eldoutilities.config.ConfigKey<T>
- Type Parameters:
T
- type of file class- Record Components:
name
- name of filepath
- path of file with file ending. Path might be relative toPlugin.getDataFolder()
configClazz
- class representing the fileinitValue
- the initial value when the file does not yet exist.
public record ConfigKey<T>(String name, Path path, Class<T> configClazz, Supplier<T> initValue)
extends Record
A key for a config file. A config key is considered unique based on the underlying path.
Two config keys pointing at the same file, but one being absolute and the other not are not considered equal. However, this should be avoided since it can cause issues when reloading or saving.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconfigClazz
record component.static <V> ConfigKey<V>
defaultConfig
(Class<V> configClazz, Supplier<V> initValue) Create a key for the default config aka config.yml.boolean
Indicates whether some other object is "equal to" this one.int
hashCode()
Returns a hash code value for this object.Returns the value of theinitValue
record component.name()
Returns the value of thename
record component.static <V> ConfigKey<V>
Create a key for the default config aka config.yml.path()
Returns the value of thepath
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
ConfigKey
Creates an instance of aConfigKey
record class.- Parameters:
name
- the value for thename
record componentpath
- the value for thepath
record componentconfigClazz
- the value for theconfigClazz
record componentinitValue
- the value for theinitValue
record component
-
-
Method Details
-
defaultConfig
Create a key for the default config aka config.yml.- Type Parameters:
V
- type of config class- Parameters:
configClazz
- class representing the config.ymlinitValue
- the initial value when the config does not yet exist.- Returns:
- config key for config.yml
-
of
public static <V> ConfigKey<V> of(String name, Path path, Class<V> configClazz, Supplier<V> initValue) Create a key for the default config aka config.yml.- Type Parameters:
V
- type of config class- Parameters:
name
- name of filepath
- path of file with file ending. Path might be relative toPlugin.getDataFolder()
configClazz
- class representing the config.ymlinitValue
- the initial value when the config does not yet exist.- Returns:
- config key for config.yml
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
name
Returns the value of thename
record component.- Returns:
- the value of the
name
record component
-
path
Returns the value of thepath
record component.- Returns:
- the value of the
path
record component
-
configClazz
Returns the value of theconfigClazz
record component.- Returns:
- the value of the
configClazz
record component
-
initValue
Returns the value of theinitValue
record component.- Returns:
- the value of the
initValue
record component
-