Skip to content

EVE SDE Schema

Documentation for third-party developers

graphics.jsonl

Schema

  • _key (required): integer
    Range: 10 .. 28250
  • graphicFile: string
  • iconFolder: string
  • sofFactionName: string
  • sofHullName: string
  • sofLayout: array of string
    Type: string
  • sofMaterialSetID: integer
    Range: 36 .. 3474
  • sofRaceName: string

Code snippets

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

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

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

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

        [JsonProperty("graphicFile", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
        public string GraphicFile { get; set; }

        [JsonProperty("iconFolder", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
        public string IconFolder { get; set; }

        [JsonProperty("sofFactionName", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
        public string SofFactionName { get; set; }

        [JsonProperty("sofHullName", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
        public string SofHullName { get; set; }

        [JsonProperty("sofLayout", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(DecodeArrayConverter))]
        public string[] SofLayout { get; set; }

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

        [JsonProperty("sofRaceName", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
        public string SofRaceName { get; set; }
    }

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

    public static class Serialize
    {
        public static string ToJson(this Graphic 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 PurpleMinMaxLengthCheckConverter : 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 >= 28 && value.Length <= 102)
            {
                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 >= 28 && value.Length <= 102)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly PurpleMinMaxLengthCheckConverter Singleton = new PurpleMinMaxLengthCheckConverter();
    }

    internal class FluffyMinMaxLengthCheckConverter : 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 >= 22 && value.Length <= 92)
            {
                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 >= 22 && value.Length <= 92)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly FluffyMinMaxLengthCheckConverter Singleton = new FluffyMinMaxLengthCheckConverter();
    }

    internal class TentacledMinMaxLengthCheckConverter : 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 >= 3 && value.Length <= 30)
            {
                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 >= 3 && value.Length <= 30)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly TentacledMinMaxLengthCheckConverter Singleton = new TentacledMinMaxLengthCheckConverter();
    }

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

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            reader.Read();
            var value = new List<string>();
            while (reader.TokenType != JsonToken.EndArray)
            {
                var converter = StickyMinMaxLengthCheckConverter.Singleton;
                var arrayItem = (string)converter.ReadJson(reader, typeof(string), null, serializer);
                value.Add(arrayItem);
                reader.Read();
            }
            return value.ToArray();
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string[])untypedValue;
            writer.WriteStartArray();
            foreach (var arrayItem in value)
            {
                var converter = StickyMinMaxLengthCheckConverter.Singleton;
                converter.WriteJson(writer, arrayItem, serializer);
            }
            writer.WriteEndArray();
            return;
        }

        public static readonly DecodeArrayConverter Singleton = new DecodeArrayConverter();
    }

    internal class StickyMinMaxLengthCheckConverter : 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 >= 10 && value.Length <= 20)
            {
                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 >= 10 && value.Length <= 20)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly StickyMinMaxLengthCheckConverter Singleton = new StickyMinMaxLengthCheckConverter();
    }

    internal class IndigoMinMaxLengthCheckConverter : 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 >= 3 && value.Length <= 10)
            {
                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 >= 3 && value.Length <= 10)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly IndigoMinMaxLengthCheckConverter Singleton = new IndigoMinMaxLengthCheckConverter();
    }
}
// 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:
//
//    graphic, err := UnmarshalGraphic(bytes)
//    bytes, err = graphic.Marshal()

package model

import "encoding/json"

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

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

type Graphic struct {
    Key              int64    `json:"_key"`
    GraphicFile      *string  `json:"graphicFile,omitempty"`
    IconFolder       *string  `json:"iconFolder,omitempty"`
    SofFactionName   *string  `json:"sofFactionName,omitempty"`
    SofHullName      *string  `json:"sofHullName,omitempty"`
    SofLayout        []string `json:"sofLayout,omitempty"`
    SofMaterialSetID *int64   `json:"sofMaterialSetID,omitempty"`
    SofRaceName      *string  `json:"sofRaceName,omitempty"`
}
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "_key": {
            "type": "integer",
            "minimum": 10,
            "maximum": 28250
        },
        "graphicFile": {
            "type": "string",
            "minLength": 28,
            "maxLength": 102
        },
        "iconFolder": {
            "type": "string",
            "minLength": 22,
            "maxLength": 92
        },
        "sofFactionName": {
            "type": "string",
            "minLength": 3,
            "maxLength": 30
        },
        "sofHullName": {
            "type": "string",
            "minLength": 3,
            "maxLength": 30
        },
        "sofLayout": {
            "type": "array",
            "items": {
                "type": "string",
                "minLength": 10,
                "maxLength": 20
            },
            "minItems": 1,
            "maxItems": 2
        },
        "sofMaterialSetID": {
            "type": "integer",
            "minimum": 36,
            "maximum": 3474
        },
        "sofRaceName": {
            "type": "string",
            "minLength": 3,
            "maxLength": 10
        }
    },
    "required": [
        "_key"
    ]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json    = Json { allowStructuredMapKeys = true }
// val graphic = json.parse(Graphic.serializer(), jsonString)

package model

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

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

    val graphicFile: String? = null,
    val iconFolder: String? = null,
    val sofFactionName: String? = null,
    val sofHullName: String? = null,
    val sofLayout: List<String>? = null,

    @SerialName("sofMaterialSetID")
    val sofMaterialSetId: Long? = null,

    val sofRaceName: String? = null
)
<?php

// This is a autogenerated file:Graphic

class Graphic {
    private int $key; // json:_key Required
    private ?string $graphicFile; // json:graphicFile Optional
    private ?string $iconFolder; // json:iconFolder Optional
    private ?string $sofFactionName; // json:sofFactionName Optional
    private ?string $sofHullName; // json:sofHullName Optional
    private ?array $sofLayout; // json:sofLayout Optional
    private ?int $sofMaterialSetId; // json:sofMaterialSetID Optional
    private ?string $sofRaceName; // json:sofRaceName Optional

    /**
     * @param int $key
     * @param string|null $graphicFile
     * @param string|null $iconFolder
     * @param string|null $sofFactionName
     * @param string|null $sofHullName
     * @param array|null $sofLayout
     * @param int|null $sofMaterialSetId
     * @param string|null $sofRaceName
     */
    public function __construct(int $key, ?string $graphicFile, ?string $iconFolder, ?string $sofFactionName, ?string $sofHullName, ?array $sofLayout, ?int $sofMaterialSetId, ?string $sofRaceName) {
        $this->key = $key;
        $this->graphicFile = $graphicFile;
        $this->iconFolder = $iconFolder;
        $this->sofFactionName = $sofFactionName;
        $this->sofHullName = $sofHullName;
        $this->sofLayout = $sofLayout;
        $this->sofMaterialSetId = $sofMaterialSetId;
        $this->sofRaceName = $sofRaceName;
    }

    /**
     * @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 (Graphic::validateKey($this->key))  {
            return $this->key; /*int*/
        }
        throw new Exception('never get to this Graphic::key');
    }

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

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

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

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

    /**
     * @throws Exception
     * @return ?string
     */
    public function toGraphicFile(): ?string {
        if (Graphic::validateGraphicFile($this->graphicFile))  {
            if (!is_null($this->graphicFile)) {
                return $this->graphicFile; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::graphicFile');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateGraphicFile(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Graphic::graphicFile");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getGraphicFile(): ?string {
        if (Graphic::validateGraphicFile($this->graphicFile))  {
            return $this->graphicFile;
        }
        throw new Exception('never get to getGraphicFile Graphic::graphicFile');
    }

    /**
     * @return ?string
     */
    public static function sampleGraphicFile(): ?string {
        return 'Graphic::graphicFile::32'; /*32:graphicFile*/
    }

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

    /**
     * @throws Exception
     * @return ?string
     */
    public function toIconFolder(): ?string {
        if (Graphic::validateIconFolder($this->iconFolder))  {
            if (!is_null($this->iconFolder)) {
                return $this->iconFolder; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::iconFolder');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateIconFolder(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Graphic::iconFolder");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getIconFolder(): ?string {
        if (Graphic::validateIconFolder($this->iconFolder))  {
            return $this->iconFolder;
        }
        throw new Exception('never get to getIconFolder Graphic::iconFolder');
    }

    /**
     * @return ?string
     */
    public static function sampleIconFolder(): ?string {
        return 'Graphic::iconFolder::33'; /*33:iconFolder*/
    }

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

    /**
     * @throws Exception
     * @return ?string
     */
    public function toSofFactionName(): ?string {
        if (Graphic::validateSofFactionName($this->sofFactionName))  {
            if (!is_null($this->sofFactionName)) {
                return $this->sofFactionName; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::sofFactionName');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateSofFactionName(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Graphic::sofFactionName");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getSofFactionName(): ?string {
        if (Graphic::validateSofFactionName($this->sofFactionName))  {
            return $this->sofFactionName;
        }
        throw new Exception('never get to getSofFactionName Graphic::sofFactionName');
    }

    /**
     * @return ?string
     */
    public static function sampleSofFactionName(): ?string {
        return 'Graphic::sofFactionName::34'; /*34:sofFactionName*/
    }

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

    /**
     * @throws Exception
     * @return ?string
     */
    public function toSofHullName(): ?string {
        if (Graphic::validateSofHullName($this->sofHullName))  {
            if (!is_null($this->sofHullName)) {
                return $this->sofHullName; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::sofHullName');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateSofHullName(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Graphic::sofHullName");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getSofHullName(): ?string {
        if (Graphic::validateSofHullName($this->sofHullName))  {
            return $this->sofHullName;
        }
        throw new Exception('never get to getSofHullName Graphic::sofHullName');
    }

    /**
     * @return ?string
     */
    public static function sampleSofHullName(): ?string {
        return 'Graphic::sofHullName::35'; /*35:sofHullName*/
    }

    /**
     * @param ?array $value
     * @throws Exception
     * @return ?array
     */
    public static function fromSofLayout(?array $value): ?array {
        if (!is_null($value)) {
            return  array_map(function ($value) {
                return $value; /*string*/
            }, $value);
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function toSofLayout(): ?array {
        if (Graphic::validateSofLayout($this->sofLayout))  {
            if (!is_null($this->sofLayout)) {
                return array_map(function ($value) {
                    return $value; /*string*/
                }, $this->sofLayout);
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::sofLayout');
    }

    /**
     * @param array|null
     * @return bool
     * @throws Exception
     */
    public static function validateSofLayout(?array $value): bool {
        if (!is_null($value)) {
            if (!is_array($value)) {
                throw new Exception("Attribute Error:Graphic::sofLayout");
            }
            array_walk($value, function($value_v) {
                if (!is_string($value_v)) {
                    throw new Exception("Attribute Error:Graphic::sofLayout");
                }
            });
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?array
     */
    public function getSofLayout(): ?array {
        if (Graphic::validateSofLayout($this->sofLayout))  {
            return $this->sofLayout;
        }
        throw new Exception('never get to getSofLayout Graphic::sofLayout');
    }

    /**
     * @return ?array
     */
    public static function sampleSofLayout(): ?array {
        return  array(
            'Graphic::::36' /*36:*/
        ); /* 36:sofLayout*/
    }

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

    /**
     * @throws Exception
     * @return ?int
     */
    public function toSofMaterialSetId(): ?int {
        if (Graphic::validateSofMaterialSetId($this->sofMaterialSetId))  {
            if (!is_null($this->sofMaterialSetId)) {
                return $this->sofMaterialSetId; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::sofMaterialSetId');
    }

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

    /**
     * @throws Exception
     * @return ?int
     */
    public function getSofMaterialSetId(): ?int {
        if (Graphic::validateSofMaterialSetId($this->sofMaterialSetId))  {
            return $this->sofMaterialSetId;
        }
        throw new Exception('never get to getSofMaterialSetId Graphic::sofMaterialSetId');
    }

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

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

    /**
     * @throws Exception
     * @return ?string
     */
    public function toSofRaceName(): ?string {
        if (Graphic::validateSofRaceName($this->sofRaceName))  {
            if (!is_null($this->sofRaceName)) {
                return $this->sofRaceName; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Graphic::sofRaceName');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateSofRaceName(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Graphic::sofRaceName");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getSofRaceName(): ?string {
        if (Graphic::validateSofRaceName($this->sofRaceName))  {
            return $this->sofRaceName;
        }
        throw new Exception('never get to getSofRaceName Graphic::sofRaceName');
    }

    /**
     * @return ?string
     */
    public static function sampleSofRaceName(): ?string {
        return 'Graphic::sofRaceName::38'; /*38:sofRaceName*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Graphic::validateKey($this->key)
        || Graphic::validateGraphicFile($this->graphicFile)
        || Graphic::validateIconFolder($this->iconFolder)
        || Graphic::validateSofFactionName($this->sofFactionName)
        || Graphic::validateSofHullName($this->sofHullName)
        || Graphic::validateSofLayout($this->sofLayout)
        || Graphic::validateSofMaterialSetId($this->sofMaterialSetId)
        || Graphic::validateSofRaceName($this->sofRaceName);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'_key'} = $this->toKey();
        $out->{'graphicFile'} = $this->toGraphicFile();
        $out->{'iconFolder'} = $this->toIconFolder();
        $out->{'sofFactionName'} = $this->toSofFactionName();
        $out->{'sofHullName'} = $this->toSofHullName();
        $out->{'sofLayout'} = $this->toSofLayout();
        $out->{'sofMaterialSetID'} = $this->toSofMaterialSetId();
        $out->{'sofRaceName'} = $this->toSofRaceName();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Graphic
     * @throws Exception
     */
    public static function from(stdClass $obj): Graphic {
        return new Graphic(
         Graphic::fromKey($obj->{'_key'})
        ,Graphic::fromGraphicFile($obj->{'graphicFile'})
        ,Graphic::fromIconFolder($obj->{'iconFolder'})
        ,Graphic::fromSofFactionName($obj->{'sofFactionName'})
        ,Graphic::fromSofHullName($obj->{'sofHullName'})
        ,Graphic::fromSofLayout($obj->{'sofLayout'})
        ,Graphic::fromSofMaterialSetId($obj->{'sofMaterialSetID'})
        ,Graphic::fromSofRaceName($obj->{'sofRaceName'})
        );
    }

    /**
     * @return Graphic
     */
    public static function sample(): Graphic {
        return new Graphic(
         Graphic::sampleKey()
        ,Graphic::sampleGraphicFile()
        ,Graphic::sampleIconFolder()
        ,Graphic::sampleSofFactionName()
        ,Graphic::sampleSofHullName()
        ,Graphic::sampleSofLayout()
        ,Graphic::sampleSofMaterialSetId()
        ,Graphic::sampleSofRaceName()
        );
    }
}
from typing import Optional, List, Any, TypeVar, Callable, Type, cast


T = TypeVar("T")


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


def from_str(x: Any) -> str:
    assert isinstance(x, str)
    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_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()


class Graphic:
    key: int
    graphic_file: Optional[str]
    icon_folder: Optional[str]
    sof_faction_name: Optional[str]
    sof_hull_name: Optional[str]
    sof_layout: Optional[List[str]]
    sof_material_set_id: Optional[int]
    sof_race_name: Optional[str]

    def __init__(self, key: int, graphic_file: Optional[str], icon_folder: Optional[str], sof_faction_name: Optional[str], sof_hull_name: Optional[str], sof_layout: Optional[List[str]], sof_material_set_id: Optional[int], sof_race_name: Optional[str]) -> None:
        self.key = key
        self.graphic_file = graphic_file
        self.icon_folder = icon_folder
        self.sof_faction_name = sof_faction_name
        self.sof_hull_name = sof_hull_name
        self.sof_layout = sof_layout
        self.sof_material_set_id = sof_material_set_id
        self.sof_race_name = sof_race_name

    @staticmethod
    def from_dict(obj: Any) -> 'Graphic':
        assert isinstance(obj, dict)
        key = from_int(obj.get("_key"))
        graphic_file = from_union([from_str, from_none], obj.get("graphicFile"))
        icon_folder = from_union([from_str, from_none], obj.get("iconFolder"))
        sof_faction_name = from_union([from_str, from_none], obj.get("sofFactionName"))
        sof_hull_name = from_union([from_str, from_none], obj.get("sofHullName"))
        sof_layout = from_union([lambda x: from_list(from_str, x), from_none], obj.get("sofLayout"))
        sof_material_set_id = from_union([from_int, from_none], obj.get("sofMaterialSetID"))
        sof_race_name = from_union([from_str, from_none], obj.get("sofRaceName"))
        return Graphic(key, graphic_file, icon_folder, sof_faction_name, sof_hull_name, sof_layout, sof_material_set_id, sof_race_name)

    def to_dict(self) -> dict:
        result: dict = {}
        result["_key"] = from_int(self.key)
        if self.graphic_file is not None:
            result["graphicFile"] = from_union([from_str, from_none], self.graphic_file)
        if self.icon_folder is not None:
            result["iconFolder"] = from_union([from_str, from_none], self.icon_folder)
        if self.sof_faction_name is not None:
            result["sofFactionName"] = from_union([from_str, from_none], self.sof_faction_name)
        if self.sof_hull_name is not None:
            result["sofHullName"] = from_union([from_str, from_none], self.sof_hull_name)
        if self.sof_layout is not None:
            result["sofLayout"] = from_union([lambda x: from_list(from_str, x), from_none], self.sof_layout)
        if self.sof_material_set_id is not None:
            result["sofMaterialSetID"] = from_union([from_int, from_none], self.sof_material_set_id)
        if self.sof_race_name is not None:
            result["sofRaceName"] = from_union([from_str, from_none], self.sof_race_name)
        return result


def graphic_from_dict(s: Any) -> Graphic:
    return Graphic.from_dict(s)


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

export interface Graphic {
    _key:              number;
    graphicFile?:      string;
    iconFolder?:       string;
    sofFactionName?:   string;
    sofHullName?:      string;
    sofLayout?:        string[];
    sofMaterialSetID?: number;
    sofRaceName?:      string;
    [property: string]: any;
}

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

    public static graphicToJson(value: Graphic): string {
        return JSON.stringify(uncast(value, r("Graphic")), 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 = {
    "Graphic": o([
        { json: "_key", js: "_key", typ: 0 },
        { json: "graphicFile", js: "graphicFile", typ: u(undefined, "") },
        { json: "iconFolder", js: "iconFolder", typ: u(undefined, "") },
        { json: "sofFactionName", js: "sofFactionName", typ: u(undefined, "") },
        { json: "sofHullName", js: "sofHullName", typ: u(undefined, "") },
        { json: "sofLayout", js: "sofLayout", typ: u(undefined, a("")) },
        { json: "sofMaterialSetID", js: "sofMaterialSetID", typ: u(undefined, 0) },
        { json: "sofRaceName", js: "sofRaceName", typ: u(undefined, "") },
    ], "any"),
};