Record Class AddonConfiguration
java.lang.Object
java.lang.Record
de.craftsblock.craftsnet.addon.meta.AddonConfiguration
- Record Components:
path- ThePathwhich contains the addon.json-Jsonrepresentation of the addon configuration.classpath- Array ofURLs representing the classpath of the addon.dependencyLoaders- An array ofdependency class loaderswhich are used to load classes from the dependencies.services- Collection ofRegisteredServiceinstances associated with the addon.addon- Reference to the actualAddoninstance.meta- Reference to theAddonMetametadata of the addon.
- All Implemented Interfaces:
Comparable<AddonConfiguration>
public record AddonConfiguration(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services, AtomicReference<Addon> addon, AtomicReference<AddonMeta> meta, AtomicReference<AddonClassLoader> classLoader)
extends Record
implements Comparable<AddonConfiguration>
Represents the configuration details of an
Addon, including its metadata, classpath, and dependencies.
This class serves as a container for storing and managing the runtime configuration of addons, ensuring proper dependency management and validation of addon metadata.
- Since:
- 3.1.0-SNAPSHOT
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAddonConfiguration(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services, AtomicReference<Addon> addon, AtomicReference<AddonMeta> meta, AtomicReference<AddonClassLoader> classLoader) Creates an instance of aAddonConfigurationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionaddon()Returns the value of theaddonrecord component.Returns the value of theclassLoaderrecord component.URL[]Returns the value of theclasspathrecord component.intcompareTo(@NotNull AddonConfiguration o) Compares this configuration to another based on their addon names.Returns the value of thedependencyLoadersrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.de.craftsblock.craftscore.json.Jsonjson()Returns the value of thejsonrecord component.static voidMaps an addon class to a custom name.meta()Returns the value of themetarecord component.static List<AddonConfiguration>of(CraftsNet craftsNet, AddonLoader loader, Class<? extends Addon> addon) Creates a list ofAddonConfigurationinstances from the providedAddonclass, including its dependencies.static AddonConfigurationof(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services) Creates anAddonConfigurationinstance from the provided params.path()Returns the value of thepathrecord component.services()Returns the value of theservicesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NAME_VALIDATOR
Pattern for validating addon names.Addon names can only contain alphanumeric characters.
-
-
Constructor Details
-
AddonConfiguration
public AddonConfiguration(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services, AtomicReference<Addon> addon, AtomicReference<AddonMeta> meta, AtomicReference<AddonClassLoader> classLoader) Creates an instance of aAddonConfigurationrecord class.- Parameters:
path- the value for thepathrecord componentjson- the value for thejsonrecord componentclasspath- the value for theclasspathrecord componentdependencyLoaders- the value for thedependencyLoadersrecord componentservices- the value for theservicesrecord componentaddon- the value for theaddonrecord componentmeta- the value for themetarecord componentclassLoader- the value for theclassLoaderrecord component
-
-
Method Details
-
of
public static AddonConfiguration of(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services) Creates anAddonConfigurationinstance from the provided params.- Parameters:
path- ThePathwhich contains the addon.json-Jsonrepresentation of the addon configuration.classpath- Array ofURLs representing the classpath of the addon.dependencyLoaders- An array ofdependency class loaderswhich are used to load classes from the dependencies.services- Collection ofRegisteredServiceinstances associated with the addon.- Returns:
- A new instance of
AddonConfiguration.
-
of
public static List<AddonConfiguration> of(CraftsNet craftsNet, AddonLoader loader, Class<? extends Addon> addon) Creates a list ofAddonConfigurationinstances from the providedAddonclass, including its dependencies.- Parameters:
craftsNet- The instance ofCraftsNetloading the addon for.loader- The instance ofAddonLoaderwhich loads the addon.addon- The addon class for which the configuration should be created.- Returns:
- A list of
AddonConfiguration, including the configuration of the addon and its dependencies. - Throws:
IllegalStateException- If the provided addon class is not annotated withMeta.
-
compareTo
Compares this configuration to another based on their addon names.- Specified by:
compareToin interfaceComparable<AddonConfiguration>- Parameters:
o- The otherAddonConfiguration.- Returns:
- A negative integer, zero, or a positive integer as this configuration's name is lexicographically less than, equal to, or greater than the other configuration's name.
-
map
Maps an addon class to a custom name.- Parameters:
addon- The addon class.name- The name to associate with the addon class.
-
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. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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). -
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
json
public de.craftsblock.craftscore.json.Json json()Returns the value of thejsonrecord component.- Returns:
- the value of the
jsonrecord component
-
classpath
Returns the value of theclasspathrecord component.- Returns:
- the value of the
classpathrecord component
-
dependencyLoaders
Returns the value of thedependencyLoadersrecord component.- Returns:
- the value of the
dependencyLoadersrecord component
-
services
Returns the value of theservicesrecord component.- Returns:
- the value of the
servicesrecord component
-
addon
Returns the value of theaddonrecord component.- Returns:
- the value of the
addonrecord component
-
meta
Returns the value of themetarecord component.- Returns:
- the value of the
metarecord component
-
classLoader
Returns the value of theclassLoaderrecord component.- Returns:
- the value of the
classLoaderrecord component
-