dakotahnorth-organization / CoralME-sweep

A simple, fast and garbage-free matching engine order book that you can use as a starting point for your matching engines.
Apache License 2.0
0 stars 0 forks source link

Refactor Order class by extracting enums into separate files #2

Open sweep-ai[bot] opened 12 hours ago

sweep-ai[bot] commented 12 hours ago

Purpose

This pull request refactors the Order class by extracting all enum definitions into their own separate files to improve code organization and maintainability.

This pull request was created to solve the following GitHub issue:

Refactor the enums in Order.java to separate files

Purpose

Refactor the enums in Order.java to separate files to improve code organization and maintainability.

Description

Moveg each enum type (like TimeInForce, RejectReason, etc.) from Order.java into its own Java file.

Summary

The changes in this pull request include:

  • Created new files for each enum in src/main/java/com/coralblocks/coralme/:
    • TimeInForce.java
    • RejectReason.java
    • CancelRejectReason.java
    • CancelReason.java
    • ReduceRejectReason.java
    • Type.java
    • ExecuteSide.java
    • Side.java
  • Moved the enum definitions from Order.java to the respective new files
  • Updated Order.java to remove the enum definitions and add import statements for the newly created enum files
  • Updated references to the enums throughout the codebase to point to the new locations

Extract Order Enums to Separate Files

Description:

Move each enum from Order.java into its own file to improve code organization and maintainability. Each enum will maintain its existing functionality while being housed in a dedicated file.

Tasks:

  1. Create new enum files in src/main/java/com/coralblocks/coralme/:

    • TimeInForce.java
    • RejectReason.java
    • CancelRejectReason.java
    • CancelReason.java
    • ReduceRejectReason.java
    • Type.java
    • ExecuteSide.java
    • Side.java
  2. In Order.java:

    • Remove all enum definitions
    • Add imports for the new enum files
    • Update any direct enum references
  3. For each new enum file:

    • Include the same package declaration
    • Copy the complete enum definition including all fields, constructors and methods
    • Import required utility classes (CharEnum, CharMap, StringUtils)

Test:

  • Verify enum functionality remains identical:
    • Character mapping
    • FIX code conversion
    • Side indexing
    • Price comparison methods
    • String conversion methods

Description

The following enums have been extracted from the Order class into their own files:

The Order class has been simplified by removing these enum definitions while maintaining all existing functionality. All references have been updated to use the new enum files.

Summary

Fixes

Fixes #1. Continue the conversation here: https://app.sweep.dev/c/6f07e953-3f49-464d-ba5e-38862d72d621.

To have Sweep make further changes, please add a comment to this PR starting with "Sweep:".

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: 4f136bd62d
sweep-ai[bot] commented 12 hours ago

❌ Error while fixing CI

Traceback (most recent call last):
  File "/app/sweepai/handlers/fix_ci.py", line 249, in fix_ci_failures_once
    pending_runs, successful_runs, error_runs = wait_for_ci_failures(pull_request)
ValueError: not enough values to unpack (expected 3, got 2)

not enough values to unpack (expected 3, got 2)

Sweep has encountered a runtime error unrelated to your request. Please let us know via this link or at support@sweep.dev directly.

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: 4f136bd62d-ci-6
sweep-ai[bot] commented 12 hours ago

Hey @sweep-ai[bot], here is an example of how you can ask me to improve this pull request:

@sweep Add unit tests for each extracted enum class to verify:
- Character mapping functionality (getChar() and CharMap)
- FIX code conversion (fromFixCode()) for enums that have FIX codes
- Special methods like Side.index(), Side.invertedIndex(), Side.isOutside(), etc.

:book: For more information on how to use Sweep, please read our documentation.