Class ScalingAlgorithmRegistryImpl
java.lang.Object
io.artificial.enchantments.internal.scaling.ScalingAlgorithmRegistryImpl
- All Implemented Interfaces:
ScalingAlgorithmRegistry
Thread-safe implementation of ScalingAlgorithmRegistry.
Uses ConcurrentHashMap for thread-safe concurrent access. Pre-registers all built-in algorithms on construction.
- Since:
- 0.2.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new registry and pre-registers all built-in algorithms. -
Method Summary
Modifier and TypeMethodDescription@NotNull LevelScalingGets a scaling algorithm by name with the specified parameters.@NotNull Optional<ScalingAlgorithmMetadata> getMetadata(@NotNull String name) Gets the metadata for a registered algorithm.Gets all registered algorithm names.booleanhasAlgorithm(@NotNull String name) Checks if an algorithm with the specified name is registered.voidregister(@NotNull String name, @NotNull ScalingAlgorithm algorithm) Registers a custom scaling algorithm with a unique name.booleanunregister(@NotNull String name) Unregisters a custom algorithm by name.
-
Constructor Details
-
ScalingAlgorithmRegistryImpl
public ScalingAlgorithmRegistryImpl()Creates a new registry and pre-registers all built-in algorithms.
-
-
Method Details
-
register
Description copied from interface:ScalingAlgorithmRegistryRegisters a custom scaling algorithm with a unique name.The algorithm name must be unique and non-empty. Attempting to register an algorithm with a name that already exists will throw an exception.
- Specified by:
registerin interfaceScalingAlgorithmRegistry- Parameters:
name- the unique algorithm name (must not be null or empty)algorithm- the algorithm implementation (must not be null)
-
get
Description copied from interface:ScalingAlgorithmRegistryGets a scaling algorithm by name with the specified parameters.The algorithm creates a
LevelScalinginstance configured with the provided parameters. The parameters are validated to ensure they produce finite values.- Specified by:
getin interfaceScalingAlgorithmRegistry- Parameters:
name- the algorithm name (must not be null or empty)params- the algorithm-specific parameters- Returns:
- a configured LevelScaling instance
-
hasAlgorithm
Description copied from interface:ScalingAlgorithmRegistryChecks if an algorithm with the specified name is registered.- Specified by:
hasAlgorithmin interfaceScalingAlgorithmRegistry- Parameters:
name- the algorithm name to check (must not be null)- Returns:
- true if the algorithm exists
-
getRegisteredNames
Description copied from interface:ScalingAlgorithmRegistryGets all registered algorithm names.- Specified by:
getRegisteredNamesin interfaceScalingAlgorithmRegistry- Returns:
- an unmodifiable set of all algorithm names
-
getMetadata
@NotNull public @NotNull Optional<ScalingAlgorithmMetadata> getMetadata(@NotNull @NotNull String name) Description copied from interface:ScalingAlgorithmRegistryGets the metadata for a registered algorithm.- Specified by:
getMetadatain interfaceScalingAlgorithmRegistry- Parameters:
name- the algorithm name (must not be null)- Returns:
- the algorithm metadata if found, empty otherwise
-
unregister
Description copied from interface:ScalingAlgorithmRegistryUnregisters a custom algorithm by name.Built-in algorithms cannot be unregistered. Attempting to unregister a built-in algorithm will return false.
- Specified by:
unregisterin interfaceScalingAlgorithmRegistry- Parameters:
name- the algorithm name to unregister (must not be null)- Returns:
- true if the algorithm was unregistered, false if not found or built-in
-