Record Class EnergyUnit
java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.common.energy.EnergyUnit
- Record Components:
id- unique identifier of the unitsymbol- display symbol (e.g. FE, RF)conversionRate- multiplier relative to the base unit
-
Constructor Summary
ConstructorsConstructorDescriptionEnergyUnit(net.kyori.adventure.key.Key id, String symbol, double conversionRate) Creates an instance of aEnergyUnitrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theconversionRaterecord component.doubleconvert(double amount, EnergyUnit to) Converts an amount from this unit into another unit.final booleanIndicates whether some other object is "equal to" this one.doublefromBase(double amount) Converts a value from the base unit into this unit.final inthashCode()Returns a hash code value for this object.net.kyori.adventure.key.Keyid()Returns the value of theidrecord component.symbol()Returns the value of thesymbolrecord component.doubletoBase(double amount) Converts a value into the base unit.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
EnergyUnit
Creates an instance of aEnergyUnitrecord class.- Parameters:
id- the value for theidrecord componentsymbol- the value for thesymbolrecord componentconversionRate- the value for theconversionRaterecord component
-
-
Method Details
-
convert
Converts an amount from this unit into another unit.- Parameters:
amount- the value in this unitto- the target unit- Returns:
- converted value in the target unit
-
toBase
public double toBase(double amount) Converts a value into the base unit.- Parameters:
amount- value in this unit- Returns:
- value in base unit
-
fromBase
public double fromBase(double amount) Converts a value from the base unit into this unit.- Parameters:
amount- value in base unit- Returns:
- value in this unit
-
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. -
id
-
symbol
-
conversionRate
public double conversionRate()Returns the value of theconversionRaterecord component.- Returns:
- the value of the
conversionRaterecord component
-