Record Class UpgradeNumberModifier
java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.skill.modifier.UpgradeNumberModifier
- Record Components:
value- the numeric amount to add or subtracttype- the operation to perform (UpgradeNumberModifier.Type.AddorUpgradeNumberModifier.Type.Subtract)
- All Implemented Interfaces:
UpgradeModifier<Number>
public record UpgradeNumberModifier(Number value, UpgradeNumberModifier.Type type)
extends Record
implements UpgradeModifier<Number>
An
UpgradeModifier for generic numeric skill parameters (doubles, floats, etc.).
Performs addition or subtraction on Number values using BigDecimal
arithmetic for precision. This is the general-purpose numeric modifier; for
integer-only parameters prefer UpgradeIntegerModifier which returns an
int directly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe arithmetic operation a numeric upgrade modifier can perform. -
Constructor Summary
ConstructorsConstructorDescriptionUpgradeNumberModifier(Number value, UpgradeNumberModifier.Type type) Creates an instance of aUpgradeNumberModifierrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Applies the inverse of this modifier's operation.Applies this modifier to the given current value, producing an updated result.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
modify
Applies this modifier to the given current value, producing an updated result.Adds or subtracts this modifier's value from the given number, depending on the configured
UpgradeNumberModifier.Type. Returns aBigDecimal.- Specified by:
modifyin interfaceUpgradeModifier<Number>- Parameters:
n- the current parameter value before modification- Returns:
- the modified parameter value
-
invert
Applies the inverse of this modifier's operation.If the type is
UpgradeNumberModifier.Type.Add, this subtracts; ifUpgradeNumberModifier.Type.Subtract, this adds. Useful for rolling back an upgrade or computing the previous level's value.- Parameters:
n- the number to un-modify- Returns:
- the result of the inverse operation
-
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). -
value
Returns the value of thevaluerecord component.- Specified by:
valuein interfaceUpgradeModifier<Number>- Returns:
- the value of the
valuerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-