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

    Constructors
    Constructor
    Description
    AttributeModifier(Modification mod, double modifyValue)
    Constructs a new PropertyModifier with the specified modification type and value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a PropertyChangeListener to the listener list.
    int
    compareTo(AttributeModifier<T> otherModifier)
    Compares this PropertyModifier with the specified PropertyModifier for order.
    boolean
    Checks if this PropertyModifier is equal to the specified object.
    Gets the type of modification to be applied.
    double
    Gets the value to be used for the modification.
    boolean
    Checks if this PropertyModifier is currently active.
    modify(T modValue)
    Modifies the given value based on the modification type and value of this PropertyModifier.
    void
    Removes a PropertyChangeListener from the listener list.
    void
    setActive(boolean active)
    Sets the active state of this PropertyModifier and fires a property change event if the state changes.
    void
    setModifyValue(double value)
    Sets the modification value for this PropertyModifier and fires a property change event if the value changes.

    Methods inherited from class Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AttributeModifier

      public AttributeModifier(Modification mod, double modifyValue)
      Constructs a new PropertyModifier with the specified modification type and value.
      Parameters:
      mod - the type of modification to be applied
      modifyValue - the value to be used for the modification
  • Method Details

    • compareTo

      public int compareTo(AttributeModifier<T> otherModifier)
      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:
      compareTo in interface Comparable<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

      public boolean equals(Object obj)
      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.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if the specified object is equal to this PropertyModifier, false otherwise
    • addListener

      public void addListener(PropertyChangeListener listener)
      Adds a PropertyChangeListener to the listener list.
      Parameters:
      listener - the PropertyChangeListener to be added
    • removeListener

      public void removeListener(PropertyChangeListener listener)
      Removes a PropertyChangeListener from the listener list.
      Parameters:
      listener - the PropertyChangeListener to be removed
    • getModification

      public Modification 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

      public T modify(T modValue)
      Modifies the given value based on the modification type and value of this PropertyModifier. If the PropertyModifier is not active, the original value is returned.
      Parameters:
      modValue - the value to be modified
      Returns:
      the modified value