Record Class AttributeModifier
java.lang.Object
java.lang.Record
fr.fidorial.attribute.AttributeModifier
- Record Components:
attribute- the attribute changed, seeAttributeKeysid- the identifier of the modifier, unique per attributeamount- the amount applied, interpreted according tooperationoperation- how the amount combines with the attribute valueslot- the equipment slots the modifier applies in
public record AttributeModifier(Key attribute, Key id, double amount, AttributeModifier.Operation operation, EquipmentSlotGroup slot)
extends Record
A change applied to an attribute of the entity wearing or holding an item.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the amount of a modifier combines with the attribute value. -
Constructor Summary
ConstructorsConstructorDescriptionAttributeModifier(Key attribute, Key id, double amount, AttributeModifier.Operation operation, EquipmentSlotGroup slot) Validates the components. -
Method Summary
Modifier and TypeMethodDescriptiondoubleamount()Returns the value of theamountrecord component.Returns the value of theattributerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static AttributeModifierof(Key attribute, Key id, double amount, AttributeModifier.Operation operation) Creates a modifier applying in any slot.static AttributeModifierof(Key attribute, Key id, double amount, AttributeModifier.Operation operation, EquipmentSlotGroup slot) Creates a modifier.Returns the value of theoperationrecord component.slot()Returns the value of theslotrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AttributeModifier
public AttributeModifier(Key attribute, Key id, double amount, AttributeModifier.Operation operation, EquipmentSlotGroup slot) Validates the components.
-
-
Method Details
-
of
public static AttributeModifier of(Key attribute, Key id, double amount, AttributeModifier.Operation operation, EquipmentSlotGroup slot) Creates a modifier.- Parameters:
attribute- the attribute changedid- the identifier of the modifieramount- the amount appliedoperation- how the amount combines with the attribute valueslot- the equipment slots the modifier applies in- Returns:
- the modifier
- Since:
- 0.1.0
-
of
public static AttributeModifier of(Key attribute, Key id, double amount, AttributeModifier.Operation operation) Creates a modifier applying in any slot.- Parameters:
attribute- the attribute changedid- the identifier of the modifieramount- the amount appliedoperation- how the amount combines with the attribute value- Returns:
- the modifier
- Since:
- 0.1.0
-
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
attribute
-
id
-
amount
-
operation
-
slot
-