Package dev.kitteh.factions.upgrade
Record Class UpgradeVariable
java.lang.Object
java.lang.Record
dev.kitteh.factions.upgrade.UpgradeVariable
- Record Components:
name- namemin- minimum valuemax- maximum valueformatter- 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 Summary
ConstructorsConstructorDescriptionUpgradeVariable(String name, BigDecimal min, BigDecimal max, Function<BigDecimal, String> formatter) Creates an instance of aUpgradeVariablerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theformatterrecord component.get(BigDecimal value) Clamps an input value to the min and max values the variable can have.final inthashCode()Returns a hash code value for this object.max()Returns the value of themaxrecord component.min()Returns the value of theminrecord component.name()Returns the value of thenamerecord component.static UpgradeVariableof(String name, BigDecimal min, BigDecimal max) Helper to create a variable that just outputs the value as a plain string.static UpgradeVariableofDuration(String name) Helper to create a variable tracking a duration.static UpgradeVariableofInteger(String name, BigDecimal min, BigDecimal max) Helper to create a variable that always outputs as an integer value.static UpgradeVariableofPercent(String name, BigDecimal min, BigDecimal max) Helper to create a variable that outputs as a percent.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
UpgradeVariable
public UpgradeVariable(String name, BigDecimal min, BigDecimal max, Function<BigDecimal, String> formatter) Creates an instance of aUpgradeVariablerecord class.
-
-
Method Details
-
of
Helper to create a variable that just outputs the value as a plain string.- Parameters:
name- namemin- minimum valuemax- maximum value- Returns:
- variable with these settings
-
ofInteger
Helper to create a variable that always outputs as an integer value.- Parameters:
name- namemin- minimum valuemax- maximum value- Returns:
- variable with these settings
-
ofPercent
Helper to create a variable that outputs as a percent.- Parameters:
name- namemin- minimum valuemax- maximum value- Returns:
- variable with these settings
-
ofDuration
Helper to create a variable tracking a duration.- Parameters:
name- name- Returns:
- variable with these settings
-
get
Clamps an input value to the min and max values the variable can have.- Parameters:
value- input value- Returns:
- clamped value
-
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). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
min
Returns the value of theminrecord component.- Returns:
- the value of the
minrecord component
-
max
Returns the value of themaxrecord component.- Returns:
- the value of the
maxrecord component
-
formatter
Returns the value of theformatterrecord component.- Returns:
- the value of the
formatterrecord component
-