from dataclasses import dataclass
from typing import Any, List, TypeVar, Callable, Type, cast


T = TypeVar("T")


def from_str(x: Any) -> str:
    assert isinstance(x, str)
    return x


def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
    assert isinstance(x, list)
    return [f(y) for y in x]


def to_class(c: Type[T], x: Any) -> dict:
    assert isinstance(x, c)
    return cast(Any, x).to_dict()


@dataclass
class Asset:
    name: str
    ixx: str
    ixy: str
    ixz: str
    iyy: str
    izz: str
    mass: str
    posX: str
    posY: str
    posZ: str
    eulerX: str
    eulerY: str
    eulerZ: str
    iyz: str
    meshPath: str
    friction: str
    centerMassX: str
    centerMassY: str
    centerMassZ: str

    @staticmethod
    def from_dict(obj: Any) -> "Asset":
        assert isinstance(obj, dict)
        name = from_str(obj.get("name"))
        ixx = from_str(obj.get("ixx"))
        ixy = from_str(obj.get("ixy"))
        ixz = from_str(obj.get("ixz"))
        iyy = from_str(obj.get("iyy"))
        izz = from_str(obj.get("izz"))
        mass = from_str(obj.get("mass"))
        posX = from_str(obj.get("posX"))
        posY = from_str(obj.get("posY"))
        posZ = from_str(obj.get("posZ"))
        eulerX = from_str(obj.get("eulerX"))
        eulerY = from_str(obj.get("eulerY"))
        eulerZ = from_str(obj.get("eulerZ"))
        iyz = from_str(obj.get("iyz"))
        meshPath = from_str(obj.get("meshPath"))
        friction = from_str(obj.get("friction"))
        centerMassX = from_str(obj.get("centerMassX"))
        centerMassY = from_str(obj.get("centerMassY"))
        centerMassZ = from_str(obj.get("centerMassZ"))
        return Asset(
            name,
            ixx,
            ixy,
            ixz,
            iyy,
            izz,
            mass,
            posX,
            posY,
            posZ,
            eulerX,
            eulerY,
            eulerZ,
            iyz,
            meshPath,
            friction,
            centerMassX,
            centerMassY,
            centerMassZ,
        )

    def to_dict(self) -> dict:
        result: dict = {}
        result["name"] = from_str(self.name)
        result["ixx"] = from_str(self.ixx)
        result["ixy"] = from_str(self.ixy)
        result["ixz"] = from_str(self.ixz)
        result["iyy"] = from_str(self.iyy)
        result["izz"] = from_str(self.izz)
        result["mass"] = from_str(self.mass)
        result["posX"] = from_str(self.posX)
        result["posY"] = from_str(self.posY)
        result["posZ"] = from_str(self.posZ)
        result["eulerX"] = from_str(self.eulerX)
        result["eulerY"] = from_str(self.eulerY)
        result["eulerZ"] = from_str(self.eulerZ)
        result["iyz"] = from_str(self.iyz)
        result["meshPath"] = from_str(self.meshPath)
        result["friction"] = from_str(self.friction)
        result["centerMassX"] = from_str(self.centerMassX)
        result["centerMassY"] = from_str(self.centerMassY)
        result["centerMassZ"] = from_str(self.centerMassZ)
        return result


@dataclass
class RobossemblerAssets:
    assets: List[Asset]
    instances: List[Any]

    @staticmethod
    def from_dict(obj: Any) -> "RobossemblerAssets":
        assert isinstance(obj, dict)
        assets = from_list(Asset.from_dict, obj.get("assets"))
        instances = from_list(lambda x: x, obj.get("instances"))
        return RobossemblerAssets(assets, instances)

    def to_dict(self) -> dict:
        result: dict = {}
        result["assets"] = from_list(lambda x: to_class(Asset, x), self.assets)
        result["instances"] = from_list(lambda x: x, self.instances)
        return result

    def toJson(self) -> str:
        print(self.to_dict())
        return str(self.to_dict()).replace("'", '"')


def RobossemblerAssetsfromdict(s: Any) -> RobossemblerAssets:
    return RobossemblerAssets.from_dict(s)


def RobossemblerAssetstodict(x: RobossemblerAssets) -> Any:
    return to_class(RobossemblerAssets, x)
