Record Class Operation
java.lang.Object
java.lang.Record
me.thiagorigonatti.capitalgains.core.Operation
- Record Components:
operation- the type of operation, such as "buy" or "sell"unitCost- the cost per unit of the assetquantity- the number of units involved in the operationticker- the ticker symbol of the asset involved in the operation
public record Operation(String operation, BigDecimal unitCost, long quantity, String ticker)
extends Record
Represents a single financial operation involving buying or selling assets.
This record is used to model input data for capital gains calculation. Each operation includes:
- The type of operation (e.g., "buy" or "sell")
- The unit cost of the asset
- The quantity involved in the operation
- The ticker symbol of the asset involved in the operation
The ticker field is now considered in the tax calculation logic to ensure operations are grouped and
processed separately by their respective tickers, allowing for accurate tax calculations per asset.
This class is intended to be deserialized from JSON input using Jackson.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionOperation(String operation, BigDecimal unitCost, long quantity, String ticker) Creates an instance of aOperationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theoperationrecord component.longquantity()Returns the value of thequantityrecord component.ticker()Returns the value of thetickerrecord component.final StringtoString()Returns a string representation of this record class.unitCost()Returns the value of theunitCostrecord component.
-
Constructor Details
-
Method Details
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
operation
Returns the value of theoperationrecord component.- Returns:
- the value of the
operationrecord component
-
unitCost
Returns the value of theunitCostrecord component.- Returns:
- the value of the
unitCostrecord component
-
quantity
public long quantity()Returns the value of thequantityrecord component.- Returns:
- the value of the
quantityrecord component
-
ticker
Returns the value of thetickerrecord component.- Returns:
- the value of the
tickerrecord component
-