"""Java language handler implementation.

Thin delegation layer that routes requests to the actual module implementations.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

from core.languages.java.optimizer import optimize_java
from core.languages.java.testgen import testgen_java

if TYPE_CHECKING:
    from authapp.auth import AuthenticatedRequest
    from core.shared.optimizer_models import OptimizeSchema
    from core.shared.optimizer_schemas import OptimizeErrorResponseSchema, OptimizeResponseSchema
    from core.shared.testgen_models import TestGenErrorResponseSchema, TestGenResponseSchema, TestGenSchema


class JavaHandler:
    """Java language handler."""

    language = "java"

    supports_testgen = True
    supports_optimizer = True
    supports_code_repair = False
    supports_jit_rewrite = False
    supports_optimization_review = False
    supports_explanations = False

    async def testgen_generate(
        self, request: AuthenticatedRequest, data: TestGenSchema
    ) -> tuple[int, TestGenResponseSchema | TestGenErrorResponseSchema]:
        """Generate tests for Java code."""
        return await testgen_java(request, data)

    async def optimizer_optimize(
        self, request: AuthenticatedRequest, data: OptimizeSchema
    ) -> tuple[int, OptimizeResponseSchema | OptimizeErrorResponseSchema]:
        """Optimize Java code for performance."""
        return await optimize_java(request, data)
