Interface ScalingAlgorithm
public interface ScalingAlgorithm
Defines a parameterized scaling algorithm that can be registered
and used to create
LevelScaling instances.
Scaling algorithms encapsulate the logic for creating scaling formulas with specific parameters. They provide metadata about the algorithm including description and parameter requirements.
Example Implementation:
ScalingAlgorithm linear = new ScalingAlgorithm() {
@Override
public LevelScaling create(double... params) {
if (params.length < 2) {
throw new IllegalArgumentException("LINEAR requires 2 parameters: base, increment");
}
return LevelScaling.linear(params[0], params[1]);
}
@Override
public String getDescription() {
return "Linear scaling: base + (level - 1) * increment";
}
@Override
public int getParameterCount() {
return 2;
}
@Override
public String[] getParameterNames() {
return new String[]{"base", "increment"};
}
};
- Since:
- 0.2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NotNull LevelScalingcreate(double... params) Creates aLevelScalinginstance with the given parameters.@NotNull StringGets a human-readable description of this algorithm.intGets the number of parameters this algorithm requires.@NotNull String[]Gets the names of parameters for this algorithm.
-
Method Details
-
create
Creates aLevelScalinginstance with the given parameters.The parameters are algorithm-specific. The implementation should validate parameters and throw
IllegalArgumentExceptionif they are invalid.- Parameters:
params- the algorithm-specific parameters- Returns:
- a configured LevelScaling instance
- Throws:
IllegalArgumentException- if parameters are invalid- Since:
- 0.2.0
-
getDescription
Gets a human-readable description of this algorithm.- Returns:
- the algorithm description
- Since:
- 0.2.0
-
getParameterCount
int getParameterCount()Gets the number of parameters this algorithm requires.- Returns:
- the expected parameter count
- Since:
- 0.2.0
-
getParameterNames
Gets the names of parameters for this algorithm.- Returns:
- an array of parameter names, same length as
getParameterCount() - Since:
- 0.2.0
-