Record Class UpgradeVariable

java.lang.Object
java.lang.Record
dev.kitteh.factions.upgrade.UpgradeVariable
Record Components:
name - name
min - minimum value
max - maximum value
formatter - string formatter for the information

@AvailableSince("4.0.0") @NullMarked public record UpgradeVariable(String name, BigDecimal min, BigDecimal max, Function<BigDecimal,String> formatter) extends Record
An upgrade variable
  • Constructor Details

    • UpgradeVariable

      public UpgradeVariable(String name, BigDecimal min, BigDecimal max, Function<BigDecimal,String> formatter)
      Creates an instance of a UpgradeVariable record class.
      Parameters:
      name - the value for the name record component
      min - the value for the min record component
      max - the value for the max record component
      formatter - the value for the formatter record component
  • Method Details

    • of

      public static UpgradeVariable of(String name, BigDecimal min, BigDecimal max)
      Helper to create a variable that just outputs the value as a plain string.
      Parameters:
      name - name
      min - minimum value
      max - maximum value
      Returns:
      variable with these settings
    • ofInteger

      public static UpgradeVariable ofInteger(String name, BigDecimal min, BigDecimal max)
      Helper to create a variable that always outputs as an integer value.
      Parameters:
      name - name
      min - minimum value
      max - maximum value
      Returns:
      variable with these settings
    • ofPercent

      public static UpgradeVariable ofPercent(String name, BigDecimal min, BigDecimal max)
      Helper to create a variable that outputs as a percent.
      Parameters:
      name - name
      min - minimum value
      max - maximum value
      Returns:
      variable with these settings
    • ofDuration

      public static UpgradeVariable ofDuration(String name)
      Helper to create a variable tracking a duration.
      Parameters:
      name - name
      Returns:
      variable with these settings
    • get

      public BigDecimal get(BigDecimal value)
      Clamps an input value to the min and max values the variable can have.
      Parameters:
      value - input value
      Returns:
      clamped value
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • min

      public BigDecimal min()
      Returns the value of the min record component.
      Returns:
      the value of the min record component
    • max

      public BigDecimal max()
      Returns the value of the max record component.
      Returns:
      the value of the max record component
    • formatter

      public Function<BigDecimal,String> formatter()
      Returns the value of the formatter record component.
      Returns:
      the value of the formatter record component