# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: oneof_default_value_serialization.proto
# plugin: python-betterproto
# This file has been @generated

from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from dataclasses import dataclass
else:
    from pydantic.dataclasses import dataclass

from datetime import (
    datetime,
    timedelta,
)
from typing import Optional

import betterproto
from pydantic import model_validator
from pydantic.dataclasses import rebuild_dataclass


@dataclass(eq=False, repr=False)
class Message(betterproto.Message):
    value: int = betterproto.int64_field(1)


@dataclass(eq=False, repr=False)
class NestedMessage(betterproto.Message):
    id: int = betterproto.int64_field(1)
    wrapped_message_value: Optional["Message"] = betterproto.message_field(
        2, optional=True, group="value_type"
    )

    @model_validator(mode="after")
    def check_oneof(cls, values):
        return cls._validate_field_groups(values)


@dataclass(eq=False, repr=False)
class Test(betterproto.Message):
    bool_value: Optional[bool] = betterproto.bool_field(
        1, optional=True, group="value_type"
    )
    int64_value: Optional[int] = betterproto.int64_field(
        2, optional=True, group="value_type"
    )
    timestamp_value: Optional[datetime] = betterproto.message_field(
        3, optional=True, group="value_type"
    )
    duration_value: Optional[timedelta] = betterproto.message_field(
        4, optional=True, group="value_type"
    )
    wrapped_message_value: Optional["Message"] = betterproto.message_field(
        5, optional=True, group="value_type"
    )
    wrapped_nested_message_value: Optional["NestedMessage"] = betterproto.message_field(
        6, optional=True, group="value_type"
    )
    wrapped_bool_value: Optional[Optional[bool]] = betterproto.message_field(
        7, wraps=betterproto.TYPE_BOOL, optional=True, group="value_type"
    )

    @model_validator(mode="after")
    def check_oneof(cls, values):
        return cls._validate_field_groups(values)


rebuild_dataclass(NestedMessage)  # type: ignore
rebuild_dataclass(Test)  # type: ignore
