feat: add CalcFunctionFactory for calculator operations (#13) #14

Merged
pitfriedrich merged 1 commits from ai/issue-13 into main 2026-07-25 18:10:54 +00:00
Collaborator

Closes #13

What

Adds a factory to com.example.util so callers can obtain a CalcFunction without knowing the implementation class.

  • CalcOperation — enum of the available operations (ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER).
  • CalcFunctionFactory.create(CalcOperation) — returns the matching CalcFunction. Exhaustive switch over the enum, so adding an operation without wiring it up is a compile error. Throws IllegalArgumentException on null.
  • LoopTestApplication now iterates CalcOperation.values() and resolves each function through the factory instead of calling constructors directly.

Tests

CalcFunctionFactoryTest covers each operation's mapping, full coverage over values(), that a created function actually calculates, and the null rejection.

./mvnw verify — 30 tests, 0 failures.

Closes #13 ## What Adds a factory to `com.example.util` so callers can obtain a `CalcFunction` without knowing the implementation class. - `CalcOperation` — enum of the available operations (`ADD`, `SUBTRACT`, `MULTIPLY`, `DIVIDE`, `POWER`). - `CalcFunctionFactory.create(CalcOperation)` — returns the matching `CalcFunction`. Exhaustive switch over the enum, so adding an operation without wiring it up is a compile error. Throws `IllegalArgumentException` on `null`. - `LoopTestApplication` now iterates `CalcOperation.values()` and resolves each function through the factory instead of calling constructors directly. ## Tests `CalcFunctionFactoryTest` covers each operation's mapping, full coverage over `values()`, that a created function actually calculates, and the null rejection. `./mvnw verify` — 30 tests, 0 failures.
claude-bot added 1 commit 2026-07-25 18:09:27 +00:00
feat: add CalcFunctionFactory for calculator operations (#13)
CI / build-and-test (pull_request) Successful in 16s
55e5cbeb0f
Callers pick an operation via the CalcOperation enum instead of
instantiating implementation classes directly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pitfriedrich started working 2026-07-25 18:10:39 +00:00
pitfriedrich merged commit 18a76b0350 into main 2026-07-25 18:10:54 +00:00
pitfriedrich worked for 16 seconds 2026-07-25 18:10:55 +00:00
pitfriedrich deleted branch ai/issue-13 2026-07-25 18:10:55 +00:00
Sign in to join this conversation.