Skip to content

EVE SDE Schema

Documentation for third-party developers

sovereigntyUpgrades.jsonl

Schema

  • _key (required): integer
    Range: 81615 .. 88763
  • fuel: object

    • hourly_upkeep (required): integer
      Range: 7 .. 205
    • startup_cost (required): integer
      Range: 1770 .. 82600
    • type_id (required): integer
      Range: 81143 .. 81144
  • mutually_exclusive_group (required): string

  • power_allocation: integer
    Range: 200 .. 1800
  • power_production: integer
    Range: 200 .. 9000
  • workforce_allocation: integer
    Range: 1500 .. 25000
  • workforce_production: integer
    Range: 5000 .. 90000

Code snippets

// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
//    using QuickType;
//
//    var sovereigntyUpgrade = SovereigntyUpgrade.FromJson(jsonString);

namespace QuickType
{
    using System;
    using System.Collections.Generic;

    using System.Globalization;
    using Newtonsoft.Json;
    using Newtonsoft.Json.Converters;

    public partial class SovereigntyUpgrade
    {
        [JsonProperty("_key")]
        public long Key { get; set; }

        [JsonProperty("fuel", NullValueHandling = NullValueHandling.Ignore)]
        public Fuel Fuel { get; set; }

        [JsonProperty("mutually_exclusive_group")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter))]
        public string MutuallyExclusiveGroup { get; set; }

        [JsonProperty("power_allocation", NullValueHandling = NullValueHandling.Ignore)]
        public long? PowerAllocation { get; set; }

        [JsonProperty("power_production", NullValueHandling = NullValueHandling.Ignore)]
        public long? PowerProduction { get; set; }

        [JsonProperty("workforce_allocation", NullValueHandling = NullValueHandling.Ignore)]
        public long? WorkforceAllocation { get; set; }

        [JsonProperty("workforce_production", NullValueHandling = NullValueHandling.Ignore)]
        public long? WorkforceProduction { get; set; }
    }

    public partial class Fuel
    {
        [JsonProperty("hourly_upkeep")]
        public long HourlyUpkeep { get; set; }

        [JsonProperty("startup_cost")]
        public long StartupCost { get; set; }

        [JsonProperty("type_id")]
        public long TypeId { get; set; }
    }

    public partial class SovereigntyUpgrade
    {
        public static SovereigntyUpgrade FromJson(string json) => JsonConvert.DeserializeObject<SovereigntyUpgrade>(json, QuickType.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this SovereigntyUpgrade self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
        {
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
            DateParseHandling = DateParseHandling.None,
            Converters =
            {
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
            },
        };
    }

    internal class MinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 5 && value.Length <= 21)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 5 && value.Length <= 21)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter Singleton = new MinMaxLengthCheckConverter();
    }
}
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
//    sovereigntyUpgrade, err := UnmarshalSovereigntyUpgrade(bytes)
//    bytes, err = sovereigntyUpgrade.Marshal()

package model

import "encoding/json"

func UnmarshalSovereigntyUpgrade(data []byte) (SovereigntyUpgrade, error) {
    var r SovereigntyUpgrade
    err := json.Unmarshal(data, &r)
    return r, err
}

func (r *SovereigntyUpgrade) Marshal() ([]byte, error) {
    return json.Marshal(r)
}

type SovereigntyUpgrade struct {
    Key                    int64  `json:"_key"`
    Fuel                   *Fuel  `json:"fuel,omitempty"`
    MutuallyExclusiveGroup string `json:"mutually_exclusive_group"`
    PowerAllocation        *int64 `json:"power_allocation,omitempty"`
    PowerProduction        *int64 `json:"power_production,omitempty"`
    WorkforceAllocation    *int64 `json:"workforce_allocation,omitempty"`
    WorkforceProduction    *int64 `json:"workforce_production,omitempty"`
}

type Fuel struct {
    HourlyUpkeep int64 `json:"hourly_upkeep"`
    StartupCost  int64 `json:"startup_cost"`
    TypeID       int64 `json:"type_id"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":81615,"maximum":88763},"fuel":{"type":"object","properties":{"hourly_upkeep":{"type":"integer","minimum":7,"maximum":205},"startup_cost":{"type":"integer","minimum":1770,"maximum":82600},"type_id":{"type":"integer","minimum":81143,"maximum":81144}},"required":["hourly_upkeep","startup_cost","type_id"]},"mutually_exclusive_group":{"type":"string","minLength":5,"maxLength":21},"power_allocation":{"type":"integer","minimum":200,"maximum":1800},"power_production":{"type":"integer","minimum":200,"maximum":9000},"workforce_allocation":{"type":"integer","minimum":1500,"maximum":25000},"workforce_production":{"type":"integer","minimum":5000,"maximum":90000}},"required":["_key","mutually_exclusive_group"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json               = Json { allowStructuredMapKeys = true }
// val sovereigntyUpgrade = json.parse(SovereigntyUpgrade.serializer(), jsonString)

package model

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@Serializable
data class SovereigntyUpgrade (
    @SerialName("_key")
    val key: Long,

    val fuel: Fuel? = null,

    @SerialName("mutually_exclusive_group")
    val mutuallyExclusiveGroup: String,

    @SerialName("power_allocation")
    val powerAllocation: Long? = null,

    @SerialName("power_production")
    val powerProduction: Long? = null,

    @SerialName("workforce_allocation")
    val workforceAllocation: Long? = null,

    @SerialName("workforce_production")
    val workforceProduction: Long? = null
)

@Serializable
data class Fuel (
    @SerialName("hourly_upkeep")
    val hourlyUpkeep: Long,

    @SerialName("startup_cost")
    val startupCost: Long,

    @SerialName("type_id")
    val typeId: Long
)
<?php

// This is a autogenerated file:SovereigntyUpgrade

class SovereigntyUpgrade {
    private int $key; // json:_key Required
    private ?Fuel $fuel; // json:fuel Optional
    private string $mutuallyExclusiveGroup; // json:mutually_exclusive_group Required
    private ?int $powerAllocation; // json:power_allocation Optional
    private ?int $powerProduction; // json:power_production Optional
    private ?int $workforceAllocation; // json:workforce_allocation Optional
    private ?int $workforceProduction; // json:workforce_production Optional

    /**
     * @param int $key
     * @param Fuel|null $fuel
     * @param string $mutuallyExclusiveGroup
     * @param int|null $powerAllocation
     * @param int|null $powerProduction
     * @param int|null $workforceAllocation
     * @param int|null $workforceProduction
     */
    public function __construct(int $key, ?Fuel $fuel, string $mutuallyExclusiveGroup, ?int $powerAllocation, ?int $powerProduction, ?int $workforceAllocation, ?int $workforceProduction) {
        $this->key = $key;
        $this->fuel = $fuel;
        $this->mutuallyExclusiveGroup = $mutuallyExclusiveGroup;
        $this->powerAllocation = $powerAllocation;
        $this->powerProduction = $powerProduction;
        $this->workforceAllocation = $workforceAllocation;
        $this->workforceProduction = $workforceProduction;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromKey(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toKey(): int {
        if (SovereigntyUpgrade::validateKey($this->key))  {
            return $this->key; /*int*/
        }
        throw new Exception('never get to this SovereigntyUpgrade::key');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateKey(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:SovereigntyUpgrade::key");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getKey(): int {
        if (SovereigntyUpgrade::validateKey($this->key))  {
            return $this->key;
        }
        throw new Exception('never get to getKey SovereigntyUpgrade::key');
    }

    /**
     * @return int
     */
    public static function sampleKey(): int {
        return 31; /*31:key*/
    }

    /**
     * @param ?stdClass $value
     * @throws Exception
     * @return ?Fuel
     */
    public static function fromFuel(?stdClass $value): ?Fuel {
        if (!is_null($value)) {
            return Fuel::from($value); /*class*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?stdClass
     */
    public function toFuel(): ?stdClass {
        if (SovereigntyUpgrade::validateFuel($this->fuel))  {
            if (!is_null($this->fuel)) {
                return $this->fuel->to(); /*class*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this SovereigntyUpgrade::fuel');
    }

    /**
     * @param Fuel|null
     * @return bool
     * @throws Exception
     */
    public static function validateFuel(?Fuel $value): bool {
        if (!is_null($value)) {
            $value->validate();
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?Fuel
     */
    public function getFuel(): ?Fuel {
        if (SovereigntyUpgrade::validateFuel($this->fuel))  {
            return $this->fuel;
        }
        throw new Exception('never get to getFuel SovereigntyUpgrade::fuel');
    }

    /**
     * @return ?Fuel
     */
    public static function sampleFuel(): ?Fuel {
        return Fuel::sample(); /*32:fuel*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromMutuallyExclusiveGroup(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toMutuallyExclusiveGroup(): string {
        if (SovereigntyUpgrade::validateMutuallyExclusiveGroup($this->mutuallyExclusiveGroup))  {
            return $this->mutuallyExclusiveGroup; /*string*/
        }
        throw new Exception('never get to this SovereigntyUpgrade::mutuallyExclusiveGroup');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateMutuallyExclusiveGroup(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:SovereigntyUpgrade::mutuallyExclusiveGroup");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getMutuallyExclusiveGroup(): string {
        if (SovereigntyUpgrade::validateMutuallyExclusiveGroup($this->mutuallyExclusiveGroup))  {
            return $this->mutuallyExclusiveGroup;
        }
        throw new Exception('never get to getMutuallyExclusiveGroup SovereigntyUpgrade::mutuallyExclusiveGroup');
    }

    /**
     * @return string
     */
    public static function sampleMutuallyExclusiveGroup(): string {
        return 'SovereigntyUpgrade::mutuallyExclusiveGroup::33'; /*33:mutuallyExclusiveGroup*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromPowerAllocation(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toPowerAllocation(): ?int {
        if (SovereigntyUpgrade::validatePowerAllocation($this->powerAllocation))  {
            if (!is_null($this->powerAllocation)) {
                return $this->powerAllocation; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this SovereigntyUpgrade::powerAllocation');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validatePowerAllocation(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:SovereigntyUpgrade::powerAllocation");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getPowerAllocation(): ?int {
        if (SovereigntyUpgrade::validatePowerAllocation($this->powerAllocation))  {
            return $this->powerAllocation;
        }
        throw new Exception('never get to getPowerAllocation SovereigntyUpgrade::powerAllocation');
    }

    /**
     * @return ?int
     */
    public static function samplePowerAllocation(): ?int {
        return 34; /*34:powerAllocation*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromPowerProduction(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toPowerProduction(): ?int {
        if (SovereigntyUpgrade::validatePowerProduction($this->powerProduction))  {
            if (!is_null($this->powerProduction)) {
                return $this->powerProduction; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this SovereigntyUpgrade::powerProduction');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validatePowerProduction(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:SovereigntyUpgrade::powerProduction");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getPowerProduction(): ?int {
        if (SovereigntyUpgrade::validatePowerProduction($this->powerProduction))  {
            return $this->powerProduction;
        }
        throw new Exception('never get to getPowerProduction SovereigntyUpgrade::powerProduction');
    }

    /**
     * @return ?int
     */
    public static function samplePowerProduction(): ?int {
        return 35; /*35:powerProduction*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromWorkforceAllocation(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toWorkforceAllocation(): ?int {
        if (SovereigntyUpgrade::validateWorkforceAllocation($this->workforceAllocation))  {
            if (!is_null($this->workforceAllocation)) {
                return $this->workforceAllocation; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this SovereigntyUpgrade::workforceAllocation');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validateWorkforceAllocation(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:SovereigntyUpgrade::workforceAllocation");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getWorkforceAllocation(): ?int {
        if (SovereigntyUpgrade::validateWorkforceAllocation($this->workforceAllocation))  {
            return $this->workforceAllocation;
        }
        throw new Exception('never get to getWorkforceAllocation SovereigntyUpgrade::workforceAllocation');
    }

    /**
     * @return ?int
     */
    public static function sampleWorkforceAllocation(): ?int {
        return 36; /*36:workforceAllocation*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromWorkforceProduction(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toWorkforceProduction(): ?int {
        if (SovereigntyUpgrade::validateWorkforceProduction($this->workforceProduction))  {
            if (!is_null($this->workforceProduction)) {
                return $this->workforceProduction; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this SovereigntyUpgrade::workforceProduction');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validateWorkforceProduction(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:SovereigntyUpgrade::workforceProduction");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getWorkforceProduction(): ?int {
        if (SovereigntyUpgrade::validateWorkforceProduction($this->workforceProduction))  {
            return $this->workforceProduction;
        }
        throw new Exception('never get to getWorkforceProduction SovereigntyUpgrade::workforceProduction');
    }

    /**
     * @return ?int
     */
    public static function sampleWorkforceProduction(): ?int {
        return 37; /*37:workforceProduction*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return SovereigntyUpgrade::validateKey($this->key)
        || SovereigntyUpgrade::validateFuel($this->fuel)
        || SovereigntyUpgrade::validateMutuallyExclusiveGroup($this->mutuallyExclusiveGroup)
        || SovereigntyUpgrade::validatePowerAllocation($this->powerAllocation)
        || SovereigntyUpgrade::validatePowerProduction($this->powerProduction)
        || SovereigntyUpgrade::validateWorkforceAllocation($this->workforceAllocation)
        || SovereigntyUpgrade::validateWorkforceProduction($this->workforceProduction);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'_key'} = $this->toKey();
        $out->{'fuel'} = $this->toFuel();
        $out->{'mutually_exclusive_group'} = $this->toMutuallyExclusiveGroup();
        $out->{'power_allocation'} = $this->toPowerAllocation();
        $out->{'power_production'} = $this->toPowerProduction();
        $out->{'workforce_allocation'} = $this->toWorkforceAllocation();
        $out->{'workforce_production'} = $this->toWorkforceProduction();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return SovereigntyUpgrade
     * @throws Exception
     */
    public static function from(stdClass $obj): SovereigntyUpgrade {
        return new SovereigntyUpgrade(
         SovereigntyUpgrade::fromKey($obj->{'_key'})
        ,SovereigntyUpgrade::fromFuel($obj->{'fuel'})
        ,SovereigntyUpgrade::fromMutuallyExclusiveGroup($obj->{'mutually_exclusive_group'})
        ,SovereigntyUpgrade::fromPowerAllocation($obj->{'power_allocation'})
        ,SovereigntyUpgrade::fromPowerProduction($obj->{'power_production'})
        ,SovereigntyUpgrade::fromWorkforceAllocation($obj->{'workforce_allocation'})
        ,SovereigntyUpgrade::fromWorkforceProduction($obj->{'workforce_production'})
        );
    }

    /**
     * @return SovereigntyUpgrade
     */
    public static function sample(): SovereigntyUpgrade {
        return new SovereigntyUpgrade(
         SovereigntyUpgrade::sampleKey()
        ,SovereigntyUpgrade::sampleFuel()
        ,SovereigntyUpgrade::sampleMutuallyExclusiveGroup()
        ,SovereigntyUpgrade::samplePowerAllocation()
        ,SovereigntyUpgrade::samplePowerProduction()
        ,SovereigntyUpgrade::sampleWorkforceAllocation()
        ,SovereigntyUpgrade::sampleWorkforceProduction()
        );
    }
}

// This is a autogenerated file:Fuel

class Fuel {
    private int $hourlyUpkeep; // json:hourly_upkeep Required
    private int $startupCost; // json:startup_cost Required
    private int $typeId; // json:type_id Required

    /**
     * @param int $hourlyUpkeep
     * @param int $startupCost
     * @param int $typeId
     */
    public function __construct(int $hourlyUpkeep, int $startupCost, int $typeId) {
        $this->hourlyUpkeep = $hourlyUpkeep;
        $this->startupCost = $startupCost;
        $this->typeId = $typeId;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromHourlyUpkeep(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toHourlyUpkeep(): int {
        if (Fuel::validateHourlyUpkeep($this->hourlyUpkeep))  {
            return $this->hourlyUpkeep; /*int*/
        }
        throw new Exception('never get to this Fuel::hourlyUpkeep');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateHourlyUpkeep(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Fuel::hourlyUpkeep");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getHourlyUpkeep(): int {
        if (Fuel::validateHourlyUpkeep($this->hourlyUpkeep))  {
            return $this->hourlyUpkeep;
        }
        throw new Exception('never get to getHourlyUpkeep Fuel::hourlyUpkeep');
    }

    /**
     * @return int
     */
    public static function sampleHourlyUpkeep(): int {
        return 31; /*31:hourlyUpkeep*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromStartupCost(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toStartupCost(): int {
        if (Fuel::validateStartupCost($this->startupCost))  {
            return $this->startupCost; /*int*/
        }
        throw new Exception('never get to this Fuel::startupCost');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateStartupCost(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Fuel::startupCost");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getStartupCost(): int {
        if (Fuel::validateStartupCost($this->startupCost))  {
            return $this->startupCost;
        }
        throw new Exception('never get to getStartupCost Fuel::startupCost');
    }

    /**
     * @return int
     */
    public static function sampleStartupCost(): int {
        return 32; /*32:startupCost*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromTypeId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toTypeId(): int {
        if (Fuel::validateTypeId($this->typeId))  {
            return $this->typeId; /*int*/
        }
        throw new Exception('never get to this Fuel::typeId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateTypeId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Fuel::typeId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getTypeId(): int {
        if (Fuel::validateTypeId($this->typeId))  {
            return $this->typeId;
        }
        throw new Exception('never get to getTypeId Fuel::typeId');
    }

    /**
     * @return int
     */
    public static function sampleTypeId(): int {
        return 33; /*33:typeId*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Fuel::validateHourlyUpkeep($this->hourlyUpkeep)
        || Fuel::validateStartupCost($this->startupCost)
        || Fuel::validateTypeId($this->typeId);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'hourly_upkeep'} = $this->toHourlyUpkeep();
        $out->{'startup_cost'} = $this->toStartupCost();
        $out->{'type_id'} = $this->toTypeId();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Fuel
     * @throws Exception
     */
    public static function from(stdClass $obj): Fuel {
        return new Fuel(
         Fuel::fromHourlyUpkeep($obj->{'hourly_upkeep'})
        ,Fuel::fromStartupCost($obj->{'startup_cost'})
        ,Fuel::fromTypeId($obj->{'type_id'})
        );
    }

    /**
     * @return Fuel
     */
    public static function sample(): Fuel {
        return new Fuel(
         Fuel::sampleHourlyUpkeep()
        ,Fuel::sampleStartupCost()
        ,Fuel::sampleTypeId()
        );
    }
}
from typing import Any, Optional, TypeVar, Type, cast


T = TypeVar("T")


def from_int(x: Any) -> int:
    assert isinstance(x, int) and not isinstance(x, bool)
    return x


def from_none(x: Any) -> Any:
    assert x is None
    return x


def from_union(fs, x):
    for f in fs:
        try:
            return f(x)
        except:
            pass
    assert False


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


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


class Fuel:
    hourly_upkeep: int
    startup_cost: int
    type_id: int

    def __init__(self, hourly_upkeep: int, startup_cost: int, type_id: int) -> None:
        self.hourly_upkeep = hourly_upkeep
        self.startup_cost = startup_cost
        self.type_id = type_id

    @staticmethod
    def from_dict(obj: Any) -> 'Fuel':
        assert isinstance(obj, dict)
        hourly_upkeep = from_int(obj.get("hourly_upkeep"))
        startup_cost = from_int(obj.get("startup_cost"))
        type_id = from_int(obj.get("type_id"))
        return Fuel(hourly_upkeep, startup_cost, type_id)

    def to_dict(self) -> dict:
        result: dict = {}
        result["hourly_upkeep"] = from_int(self.hourly_upkeep)
        result["startup_cost"] = from_int(self.startup_cost)
        result["type_id"] = from_int(self.type_id)
        return result


class SovereigntyUpgrade:
    key: int
    fuel: Optional[Fuel]
    mutually_exclusive_group: str
    power_allocation: Optional[int]
    power_production: Optional[int]
    workforce_allocation: Optional[int]
    workforce_production: Optional[int]

    def __init__(self, key: int, fuel: Optional[Fuel], mutually_exclusive_group: str, power_allocation: Optional[int], power_production: Optional[int], workforce_allocation: Optional[int], workforce_production: Optional[int]) -> None:
        self.key = key
        self.fuel = fuel
        self.mutually_exclusive_group = mutually_exclusive_group
        self.power_allocation = power_allocation
        self.power_production = power_production
        self.workforce_allocation = workforce_allocation
        self.workforce_production = workforce_production

    @staticmethod
    def from_dict(obj: Any) -> 'SovereigntyUpgrade':
        assert isinstance(obj, dict)
        key = from_int(obj.get("_key"))
        fuel = from_union([Fuel.from_dict, from_none], obj.get("fuel"))
        mutually_exclusive_group = from_str(obj.get("mutually_exclusive_group"))
        power_allocation = from_union([from_int, from_none], obj.get("power_allocation"))
        power_production = from_union([from_int, from_none], obj.get("power_production"))
        workforce_allocation = from_union([from_int, from_none], obj.get("workforce_allocation"))
        workforce_production = from_union([from_int, from_none], obj.get("workforce_production"))
        return SovereigntyUpgrade(key, fuel, mutually_exclusive_group, power_allocation, power_production, workforce_allocation, workforce_production)

    def to_dict(self) -> dict:
        result: dict = {}
        result["_key"] = from_int(self.key)
        if self.fuel is not None:
            result["fuel"] = from_union([lambda x: to_class(Fuel, x), from_none], self.fuel)
        result["mutually_exclusive_group"] = from_str(self.mutually_exclusive_group)
        if self.power_allocation is not None:
            result["power_allocation"] = from_union([from_int, from_none], self.power_allocation)
        if self.power_production is not None:
            result["power_production"] = from_union([from_int, from_none], self.power_production)
        if self.workforce_allocation is not None:
            result["workforce_allocation"] = from_union([from_int, from_none], self.workforce_allocation)
        if self.workforce_production is not None:
            result["workforce_production"] = from_union([from_int, from_none], self.workforce_production)
        return result


def sovereignty_upgrade_from_dict(s: Any) -> SovereigntyUpgrade:
    return SovereigntyUpgrade.from_dict(s)


def sovereignty_upgrade_to_dict(x: SovereigntyUpgrade) -> Any:
    return to_class(SovereigntyUpgrade, x)
// To parse this data:
//
//   import { Convert, SovereigntyUpgrade } from "./file";
//
//   const sovereigntyUpgrade = Convert.toSovereigntyUpgrade(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.

export interface SovereigntyUpgrade {
    _key:                     number;
    fuel?:                    Fuel;
    mutually_exclusive_group: string;
    power_allocation?:        number;
    power_production?:        number;
    workforce_allocation?:    number;
    workforce_production?:    number;
    [property: string]: any;
}

export interface Fuel {
    hourly_upkeep: number;
    startup_cost:  number;
    type_id:       number;
    [property: string]: any;
}

// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
    public static toSovereigntyUpgrade(json: string): SovereigntyUpgrade {
        return cast(JSON.parse(json), r("SovereigntyUpgrade"));
    }

    public static sovereigntyUpgradeToJson(value: SovereigntyUpgrade): string {
        return JSON.stringify(uncast(value, r("SovereigntyUpgrade")), null, 2);
    }
}

function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
    const prettyTyp = prettyTypeName(typ);
    const parentText = parent ? ` on ${parent}` : '';
    const keyText = key ? ` for key "${key}"` : '';
    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
}

function prettyTypeName(typ: any): string {
    if (Array.isArray(typ)) {
        if (typ.length === 2 && typ[0] === undefined) {
            return `an optional ${prettyTypeName(typ[1])}`;
        } else {
            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
        }
    } else if (typeof typ === "object" && typ.literal !== undefined) {
        return typ.literal;
    } else {
        return typeof typ;
    }
}

function jsonToJSProps(typ: any): any {
    if (typ.jsonToJS === undefined) {
        const map: any = {};
        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
        typ.jsonToJS = map;
    }
    return typ.jsonToJS;
}

function jsToJSONProps(typ: any): any {
    if (typ.jsToJSON === undefined) {
        const map: any = {};
        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
        typ.jsToJSON = map;
    }
    return typ.jsToJSON;
}

function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
    function transformPrimitive(typ: string, val: any): any {
        if (typeof typ === typeof val) return val;
        return invalidValue(typ, val, key, parent);
    }

    function transformUnion(typs: any[], val: any): any {
        // val must validate against one typ in typs
        const l = typs.length;
        for (let i = 0; i < l; i++) {
            const typ = typs[i];
            try {
                return transform(val, typ, getProps);
            } catch (_) {}
        }
        return invalidValue(typs, val, key, parent);
    }

    function transformEnum(cases: string[], val: any): any {
        if (cases.indexOf(val) !== -1) return val;
        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
    }

    function transformArray(typ: any, val: any): any {
        // val must be an array with no invalid elements
        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
        return val.map(el => transform(el, typ, getProps));
    }

    function transformDate(val: any): any {
        if (val === null) {
            return null;
        }
        const d = new Date(val);
        if (isNaN(d.valueOf())) {
            return invalidValue(l("Date"), val, key, parent);
        }
        return d;
    }

    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
        if (val === null || typeof val !== "object" || Array.isArray(val)) {
            return invalidValue(l(ref || "object"), val, key, parent);
        }
        const result: any = {};
        Object.getOwnPropertyNames(props).forEach(key => {
            const prop = props[key];
            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
        });
        Object.getOwnPropertyNames(val).forEach(key => {
            if (!Object.prototype.hasOwnProperty.call(props, key)) {
                result[key] = transform(val[key], additional, getProps, key, ref);
            }
        });
        return result;
    }

    if (typ === "any") return val;
    if (typ === null) {
        if (val === null) return val;
        return invalidValue(typ, val, key, parent);
    }
    if (typ === false) return invalidValue(typ, val, key, parent);
    let ref: any = undefined;
    while (typeof typ === "object" && typ.ref !== undefined) {
        ref = typ.ref;
        typ = typeMap[typ.ref];
    }
    if (Array.isArray(typ)) return transformEnum(typ, val);
    if (typeof typ === "object") {
        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
            : invalidValue(typ, val, key, parent);
    }
    // Numbers can be parsed by Date but shouldn't be.
    if (typ === Date && typeof val !== "number") return transformDate(val);
    return transformPrimitive(typ, val);
}

function cast<T>(val: any, typ: any): T {
    return transform(val, typ, jsonToJSProps);
}

function uncast<T>(val: T, typ: any): any {
    return transform(val, typ, jsToJSONProps);
}

function l(typ: any) {
    return { literal: typ };
}

function a(typ: any) {
    return { arrayItems: typ };
}

function u(...typs: any[]) {
    return { unionMembers: typs };
}

function o(props: any[], additional: any) {
    return { props, additional };
}

function m(additional: any) {
    return { props: [], additional };
}

function r(name: string) {
    return { ref: name };
}

const typeMap: any = {
    "SovereigntyUpgrade": o([
        { json: "_key", js: "_key", typ: 0 },
        { json: "fuel", js: "fuel", typ: u(undefined, r("Fuel")) },
        { json: "mutually_exclusive_group", js: "mutually_exclusive_group", typ: "" },
        { json: "power_allocation", js: "power_allocation", typ: u(undefined, 0) },
        { json: "power_production", js: "power_production", typ: u(undefined, 0) },
        { json: "workforce_allocation", js: "workforce_allocation", typ: u(undefined, 0) },
        { json: "workforce_production", js: "workforce_production", typ: u(undefined, 0) },
    ], "any"),
    "Fuel": o([
        { json: "hourly_upkeep", js: "hourly_upkeep", typ: 0 },
        { json: "startup_cost", js: "startup_cost", typ: 0 },
        { json: "type_id", js: "type_id", typ: 0 },
    ], "any"),
};