Index
All Classes and Interfaces|All Packages|Serialized Form
A
- ArgParser - Class in me.thiagorigonatti.capitalgains.util
-
Utility class responsible for parsing command-line arguments and applying them to a
TaxCalculatorinstance.
B
- build() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Builds and returns a new instance of
TaxCalculatorwith the configured options. - Builder() - Constructor for class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Constructs a new
Builderinstance. - Builder(String[]) - Constructor for class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Constructs a new
Builderinstance, initializing the builder with the provided arguments. - buy(long, BigDecimal) - Method in class me.thiagorigonatti.capitalgains.core.Stock
-
Processes a buy operation, increasing the number of shares and updating the average cost.
C
- calculate(String) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Parses a JSON-formatted string representing a list of operations, processes each operation to calculate a tax, and returns the result as an
ArrayNode.
D
- dumpTo(OutputStream, int) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Sets the output stream and output buffer size.
E
- equals(Object) - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Indicates whether some other object is "equal to" this one.
F
- formattedWith(DecimalFormat) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Sets the DecimalFormat to be used for formatting.
- from(InputStream, int) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Sets the input stream and input buffer size.
G
- getArgs() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the command-line arguments.
- getBufferSizeIn() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the buffer size for input.
- getBufferSizeOut() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the buffer size for output.
- getDecimalFormat() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the DecimalFormat instance used for formatting numbers.
- getInputStream() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the input stream.
- getObjectMapper() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the ObjectMapper instance.
- getOperationPredicate() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the predicate used to filter operations.
- getOutputStream() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the output stream.
- getStockSupplier() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns the supplier used to create Stock instances.
- givenAverageCost_whenSellingAtAveragePrice_thenNoTaxIsDue() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when selling at the average cost.
- givenDecimalNumber_whenFormattedWithDecimalFormat_thenMatchExpectedPattern() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for formatting a decimal number using a specific decimal format.
- givenInvalidOperation_whenCalculatingTax_thenThrowInvalidOperationException() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case to verify that an exception is thrown when an invalid operation is encountered.
- givenLossFromPreviousSale_whenSellingWithProfit_thenTaxIsAppliedOnNetProfit() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when there is a loss from previous sales.
- givenMixedOperationsWithLossAndProfit_whenCalculatingTax_thenLossesAreOffsetAndTaxIsCorrectlyApplied() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for mixed operations with both losses and profits.
- givenMultipleSalesWithAccumulatedLossesAndGains_whenCalculatingTax_thenLossesAreDeductedAndTaxApplied() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when there are multiple sales with accumulated losses and gains.
- givenMultipleTransactionsForDifferentTickers_whenCalculatingTax_thenTaxIsCalculatedBasedOnNetProfit() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when there are multiple stock transactions involving different tickers.
- givenOperationWithZeroOrNegativeQuantity_whenCalculateTax_thenThrowZeroOrNegativeQuantityException() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case to verify that an exception is thrown when an operation is performed with a zero or negative quantity.
- givenSaleExceedsAvailableQuantity_whenCalculatingTax_thenThrowInsufficientSharesException() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case to verify that an exception is thrown when a sale exceeds the available quantity of shares.
- givenSaleOver20kWithProfit_WhenCalculatingTax_thenTaxIsApplied() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when the sale amount is over 20k with profit.
- givenSalesWithAccumulatedLosses_whenCalculatingTax_thenLossesAreProperlyDeducted() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax with accumulated losses.
- givenSalesWithHighProfit_whenCalculatingTax_thenTaxIsApplied() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax on sales with high profits.
- givenSaleUnder20kWithProfit_WhenCalculatingTax_thenNoTaxIsDue() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when the sale amount is under 20k with profit.
- givenTwoIndependentSimulation_whenCalculateTax_thenReturnCorrectTaxPerOperation() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax with two independent simulations.
- givenWeightedAverageCost_whenSellingAtBreakEvenAndThenAtProfit_thenOnlyProfitIsTaxed() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Test case for calculating tax when selling at weighted average cost.
H
- hashCode() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns a hash code value for this object.
I
- InsufficientSharesException - Exception Class in me.thiagorigonatti.capitalgains.exception
-
Exception thrown when a sell operation attempts to sell more shares than are currently held.
- InsufficientSharesException(long, long) - Constructor for exception class me.thiagorigonatti.capitalgains.exception.InsufficientSharesException
-
Constructs an
InsufficientSharesExceptionwith details about the invalid request. - InvalidOperationException - Exception Class in me.thiagorigonatti.capitalgains.exception
-
Exception thrown when an unrecognized operation type is encountered during processing.
- InvalidOperationException(String) - Constructor for exception class me.thiagorigonatti.capitalgains.exception.InvalidOperationException
-
Constructs an
InvalidOperationExceptionwith a detailed error message. - isPrintEveryLine() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns whether each line should be printed.
- isTimings() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Returns whether timing information should be included.
M
- me.thiagorigonatti.capitalgains.core - package me.thiagorigonatti.capitalgains.core
-
This package contains the core logic of the Capital Gains Calculator application, including models and classes responsible for processing financial operations such as buying and selling stocks, calculating profits, and applying tax rules.
- me.thiagorigonatti.capitalgains.exception - package me.thiagorigonatti.capitalgains.exception
-
This package provides custom exception classes used to handle errors and exceptional scenarios during the execution of the application, such as invalid input formats or logical inconsistencies.
- me.thiagorigonatti.capitalgains.util - package me.thiagorigonatti.capitalgains.util
-
This package contains utility classes and helper methods used across the application, such as formatting, calculations, or data conversions that support the main application logic.
O
- onlyFor(Predicate<Operation>) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Sets a predicate to filter operations that should be considered.
- operation() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns the value of the
operationrecord component. - Operation - Record Class in me.thiagorigonatti.capitalgains.core
-
Represents a single financial operation involving buying or selling assets.
- Operation(String, BigDecimal, long, String) - Constructor for record class me.thiagorigonatti.capitalgains.core.Operation
-
Creates an instance of a
Operationrecord class.
P
- parseArgs(String[], TaxCalculator) - Static method in class me.thiagorigonatti.capitalgains.util.ArgParser
-
Parses the given command-line arguments and applies the corresponding configuration to the provided
TaxCalculatorinstance. - printEveryLine(boolean) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Specifies whether each processed line should be printed.
- processOperation(Operation, Stock) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Processes a single operation on the given
Stockinstance, modifying its state accordingly and returning the calculated tax amount (if applicable).
Q
- quantity() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns the value of the
quantityrecord component.
R
- run() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Processes input data line by line from an
InputStream, transforms each line using thecalculate(String)method, serializes the result to JSON usingobjectMapper, and writes it to anOutputStream.
S
- sell(long, BigDecimal) - Method in class me.thiagorigonatti.capitalgains.core.Stock
-
Processes a sell operation, updating shares and calculating the capital gains tax based on profit and thresholds.
- setArgs(String[]) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the command-line arguments.
- setBufferSizeIn(int) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the buffer size for input.
- setBufferSizeOut(int) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the buffer size for output.
- setDecimalFormat(DecimalFormat) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the DecimalFormat instance.
- setInputStream(InputStream) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the input stream.
- setObjectMapper(ObjectMapper) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the ObjectMapper instance.
- setOperationPredicate(Predicate<Operation>) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the predicate used to filter operations.
- setOutputStream(OutputStream) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the output stream.
- setPrintEveryLine(boolean) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets whether each line should be printed.
- setStockSupplier(Supplier<? extends Stock>) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets the supplier used to create Stock instances.
- setTimings(boolean) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Sets whether timing information should be included.
- setUp() - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Sets up the
TaxCalculatorinstance before each test. - Stock - Class in me.thiagorigonatti.capitalgains.core
-
Represents a stock position and manages buy and sell operations while tracking cost, shares, and tax calculations.
- Stock() - Constructor for class me.thiagorigonatti.capitalgains.core.Stock
-
Default constructor for the
Stockclass.
T
- TaxCalculator - Class in me.thiagorigonatti.capitalgains.core
-
Compute taxes based on a sequence of stock trading operations such as "buy" and "sell".
- TaxCalculator(TaxCalculator.Builder) - Constructor for class me.thiagorigonatti.capitalgains.core.TaxCalculator
-
Constructs a new
TaxCalculatorinstance using the providedTaxCalculator.Builder. - TaxCalculator.Builder - Class in me.thiagorigonatti.capitalgains.core
-
Builder for new instances of
TaxCalculator. - TaxCalculatorTest - Class in me.thiagorigonatti.capitalgains.core
-
Test class for the
TaxCalculatorclass, ensuring correct tax calculations for various scenarios including sales with profit, losses, and different cost methods. - TaxCalculatorTest() - Constructor for class me.thiagorigonatti.capitalgains.core.TaxCalculatorTest
-
Default constructor for TaxCalculatorTest.
- taxRate() - Method in class me.thiagorigonatti.capitalgains.core.Stock
-
Returns the applicable tax rate for capital gains.
- threshold() - Method in class me.thiagorigonatti.capitalgains.core.Stock
-
Returns the sales threshold under which capital gains are exempt from taxation.
- ticker() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns the value of the
tickerrecord component. - timings(boolean) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Specifies whether timing metrics should be recorded.
- toString() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns a string representation of this record class.
U
- unitCost() - Method in record class me.thiagorigonatti.capitalgains.core.Operation
-
Returns the value of the
unitCostrecord component.
W
- with(Supplier<? extends Stock>) - Method in class me.thiagorigonatti.capitalgains.core.TaxCalculator.Builder
-
Sets the supplier responsible for creating Stock instances.
Z
- ZeroOrNegativeQuantityException - Exception Class in me.thiagorigonatti.capitalgains.exception
-
Exception thrown when an operation attempts to process a quantity that is zero or negative.
- ZeroOrNegativeQuantityException(long) - Constructor for exception class me.thiagorigonatti.capitalgains.exception.ZeroOrNegativeQuantityException
-
Constructs a
ZeroOrNegativeQuantityExceptionwith a detailed error message.
All Classes and Interfaces|All Packages|Serialized Form