Class AttributeModifier<T extends Number>
- Type Parameters:
T- the type of the number that this modifier can modify
- All Implemented Interfaces:
Comparable<AttributeModifier<T>>
public class AttributeModifier<T extends Number>
extends Object
implements Comparable<AttributeModifier<T>>
The PropertyModifier class represents a modifier that can be applied to a property. It supports various types of modifications such as addition,
subtraction, multiplication, division, and setting a value. The class implements the Comparable interface to allow comparison based on the
modification's apply order.
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeModifier(Modification mod, double modifyValue) Constructs a new PropertyModifier with the specified modification type and value. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PropertyChangeListener listener) Adds a PropertyChangeListener to the listener list.intcompareTo(AttributeModifier<T> otherModifier) Compares this PropertyModifier with the specified PropertyModifier for order.booleanChecks if this PropertyModifier is equal to the specified object.Gets the type of modification to be applied.doubleGets the value to be used for the modification.booleanisActive()Checks if this PropertyModifier is currently active.Modifies the given value based on the modification type and value of this PropertyModifier.voidremoveListener(PropertyChangeListener listener) Removes a PropertyChangeListener from the listener list.voidsetActive(boolean active) Sets the active state of this PropertyModifier and fires a property change event if the state changes.voidsetModifyValue(double value) Sets the modification value for this PropertyModifier and fires a property change event if the value changes.
-
Constructor Details
-
AttributeModifier
Constructs a new PropertyModifier with the specified modification type and value.- Parameters:
mod- the type of modification to be appliedmodifyValue- the value to be used for the modification
-
-
Method Details
-
compareTo
Compares this PropertyModifier with the specified PropertyModifier for order. Returns a negative integer, zero, or a positive integer as this PropertyModifier's apply order is less than, equal to, or greater than the specified PropertyModifier's apply order.- Specified by:
compareToin interfaceComparable<T extends Number>- Parameters:
otherModifier- the PropertyModifier to be compared- Returns:
- a negative integer, zero, or a positive integer as this PropertyModifier is less than, equal to, or greater than the specified PropertyModifier
-
equals
Checks if this PropertyModifier is equal to the specified object. Two PropertyModifiers are considered equal if they have the same active state, modification type, and modification value. -
addListener
Adds a PropertyChangeListener to the listener list.- Parameters:
listener- the PropertyChangeListener to be added
-
removeListener
Removes a PropertyChangeListener from the listener list.- Parameters:
listener- the PropertyChangeListener to be removed
-
getModification
Gets the type of modification to be applied.- Returns:
- the modification type
-
getModifyValue
public double getModifyValue()Gets the value to be used for the modification.- Returns:
- the modification value
-
setModifyValue
public void setModifyValue(double value) Sets the modification value for this PropertyModifier and fires a property change event if the value changes.- Parameters:
value- the new modification value
-
isActive
public boolean isActive()Checks if this PropertyModifier is currently active.- Returns:
- true if this PropertyModifier is active, false otherwise
-
setActive
public void setActive(boolean active) Sets the active state of this PropertyModifier and fires a property change event if the state changes.- Parameters:
active- the new active state
-
modify
-