stationOperations.jsonl
Schema
_key
(required): integer
Range: 1 .. 121activityID
(required): integer
Range: 1 .. 20border
(required): number
Range: 0 .. 0.5corridor
(required): number
Range: 0 .. 0.5-
description
: objectde
(required): stringen
(required): stringes
(required): stringfr
(required): stringja
(required): stringko
(required): stringru
(required): stringzh
(required): string
-
fringe
(required): number
Range: 0 .. 1 hub
(required): number
Range: 0 .. 0.9manufacturingFactor
(required): number
Range: 0.5 .. 1-
operationName
(required): objectde
(required): stringen
(required): stringes
(required): stringfr
(required): stringja
(required): stringko
(required): stringru
(required): stringzh
(required): string
-
ratio
(required): number
Range: 0 .. 1 researchFactor
(required): number
Range: 0.5 .. 1services
(required): array of integer
Type:integer
Range: 1 .. 27stationTypes
: array of object_key
(required): integer
Range: 1 .. 16_value
(required): integer
Range: 54 .. 78334
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var stationOperation = StationOperation.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class StationOperation
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("activityID")]
public long ActivityId { get; set; }
[JsonProperty("border")]
[JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
public double Border { get; set; }
[JsonProperty("corridor")]
[JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
public double Corridor { get; set; }
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public Description Description { get; set; }
[JsonProperty("fringe")]
[JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
public double Fringe { get; set; }
[JsonProperty("hub")]
[JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
public double Hub { get; set; }
[JsonProperty("manufacturingFactor")]
[JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
public double ManufacturingFactor { get; set; }
[JsonProperty("operationName")]
public OperationName OperationName { get; set; }
[JsonProperty("ratio")]
[JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
public double Ratio { get; set; }
[JsonProperty("researchFactor")]
[JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
public double ResearchFactor { get; set; }
[JsonProperty("services")]
public long[] Services { get; set; }
[JsonProperty("stationTypes", NullValueHandling = NullValueHandling.Ignore)]
public StationType[] StationTypes { get; set; }
}
public partial class Description
{
[JsonProperty("de")]
[JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
public string En { get; set; }
[JsonProperty("es")]
[JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
public string Es { get; set; }
[JsonProperty("fr")]
[JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
public string Fr { get; set; }
[JsonProperty("ja")]
[JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
public string Ja { get; set; }
[JsonProperty("ko")]
[JsonConverter(typeof(IndecentMinMaxLengthCheckConverter))]
public string Ko { get; set; }
[JsonProperty("ru")]
[JsonConverter(typeof(HilariousMinMaxLengthCheckConverter))]
public string Ru { get; set; }
[JsonProperty("zh")]
[JsonConverter(typeof(AmbitiousMinMaxLengthCheckConverter))]
public string Zh { get; set; }
}
public partial class OperationName
{
[JsonProperty("de")]
[JsonConverter(typeof(CunningMinMaxLengthCheckConverter))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(MagentaMinMaxLengthCheckConverter))]
public string En { get; set; }
[JsonProperty("es")]
[JsonConverter(typeof(FriskyMinMaxLengthCheckConverter))]
public string Es { get; set; }
[JsonProperty("fr")]
[JsonConverter(typeof(MischievousMinMaxLengthCheckConverter))]
public string Fr { get; set; }
[JsonProperty("ja")]
[JsonConverter(typeof(BraggadociousMinMaxLengthCheckConverter))]
public string Ja { get; set; }
[JsonProperty("ko")]
[JsonConverter(typeof(MinMaxLengthCheckConverter1))]
public string Ko { get; set; }
[JsonProperty("ru")]
[JsonConverter(typeof(MinMaxLengthCheckConverter2))]
public string Ru { get; set; }
[JsonProperty("zh")]
[JsonConverter(typeof(MinMaxLengthCheckConverter3))]
public string Zh { get; set; }
}
public partial class StationType
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("_value")]
public long Value { get; set; }
}
public partial class StationOperation
{
public static StationOperation FromJson(string json) => JsonConvert.DeserializeObject<StationOperation>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this StationOperation 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 PurpleMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= 0 && value <= 0.5)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= 0 && value <= 0.5)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly PurpleMinMaxValueCheckConverter Singleton = new PurpleMinMaxValueCheckConverter();
}
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 >= 15 && value.Length <= 1193)
{
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 >= 15 && value.Length <= 1193)
{
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 >= 16 && value.Length <= 1077)
{
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 >= 16 && value.Length <= 1077)
{
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 >= 20 && value.Length <= 1157)
{
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 >= 20 && value.Length <= 1157)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly TentacledMinMaxLengthCheckConverter Singleton = new TentacledMinMaxLengthCheckConverter();
}
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 >= 28 && value.Length <= 1153)
{
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 <= 1153)
{
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 >= 10 && value.Length <= 462)
{
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 <= 462)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly IndigoMinMaxLengthCheckConverter Singleton = new IndigoMinMaxLengthCheckConverter();
}
internal class IndecentMinMaxLengthCheckConverter : 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 >= 8 && value.Length <= 571)
{
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 >= 8 && value.Length <= 571)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly IndecentMinMaxLengthCheckConverter Singleton = new IndecentMinMaxLengthCheckConverter();
}
internal class HilariousMinMaxLengthCheckConverter : 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 >= 21 && value.Length <= 1140)
{
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 >= 21 && value.Length <= 1140)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly HilariousMinMaxLengthCheckConverter Singleton = new HilariousMinMaxLengthCheckConverter();
}
internal class AmbitiousMinMaxLengthCheckConverter : 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 <= 288)
{
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 <= 288)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly AmbitiousMinMaxLengthCheckConverter Singleton = new AmbitiousMinMaxLengthCheckConverter();
}
internal class FluffyMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= 0 && value <= 1)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= 0 && value <= 1)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly FluffyMinMaxValueCheckConverter Singleton = new FluffyMinMaxValueCheckConverter();
}
internal class TentacledMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= 0 && value <= 0.9)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= 0 && value <= 0.9)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly TentacledMinMaxValueCheckConverter Singleton = new TentacledMinMaxValueCheckConverter();
}
internal class StickyMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= 0.5 && value <= 1)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= 0.5 && value <= 1)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly StickyMinMaxValueCheckConverter Singleton = new StickyMinMaxValueCheckConverter();
}
internal class CunningMinMaxLengthCheckConverter : 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 <= 36)
{
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 <= 36)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly CunningMinMaxLengthCheckConverter Singleton = new CunningMinMaxLengthCheckConverter();
}
internal class MagentaMinMaxLengthCheckConverter : 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 <= 31)
{
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 <= 31)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MagentaMinMaxLengthCheckConverter Singleton = new MagentaMinMaxLengthCheckConverter();
}
internal class FriskyMinMaxLengthCheckConverter : 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 >= 6 && value.Length <= 43)
{
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 >= 6 && value.Length <= 43)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly FriskyMinMaxLengthCheckConverter Singleton = new FriskyMinMaxLengthCheckConverter();
}
internal class MischievousMinMaxLengthCheckConverter : 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 <= 40)
{
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 <= 40)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MischievousMinMaxLengthCheckConverter Singleton = new MischievousMinMaxLengthCheckConverter();
}
internal class BraggadociousMinMaxLengthCheckConverter : 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 >= 2 && value.Length <= 15)
{
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 >= 2 && value.Length <= 15)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly BraggadociousMinMaxLengthCheckConverter Singleton = new BraggadociousMinMaxLengthCheckConverter();
}
internal class MinMaxLengthCheckConverter1 : 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 >= 2 && value.Length <= 16)
{
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 >= 2 && value.Length <= 16)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter1 Singleton = new MinMaxLengthCheckConverter1();
}
internal class MinMaxLengthCheckConverter2 : 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 >= 7 && value.Length <= 34)
{
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 >= 7 && value.Length <= 34)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter2 Singleton = new MinMaxLengthCheckConverter2();
}
internal class MinMaxLengthCheckConverter3 : 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 >= 2 && value.Length <= 9)
{
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 >= 2 && value.Length <= 9)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter3 Singleton = new MinMaxLengthCheckConverter3();
}
}
// 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:
//
// stationOperation, err := UnmarshalStationOperation(bytes)
// bytes, err = stationOperation.Marshal()
package model
import "encoding/json"
func UnmarshalStationOperation(data []byte) (StationOperation, error) {
var r StationOperation
err := json.Unmarshal(data, &r)
return r, err
}
func (r *StationOperation) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type StationOperation struct {
Key int64 `json:"_key"`
ActivityID int64 `json:"activityID"`
Border float64 `json:"border"`
Corridor float64 `json:"corridor"`
Description *Description `json:"description,omitempty"`
Fringe float64 `json:"fringe"`
Hub float64 `json:"hub"`
ManufacturingFactor float64 `json:"manufacturingFactor"`
OperationName OperationName `json:"operationName"`
Ratio float64 `json:"ratio"`
ResearchFactor float64 `json:"researchFactor"`
Services []int64 `json:"services"`
StationTypes []StationType `json:"stationTypes,omitempty"`
}
type Description struct {
De string `json:"de"`
En string `json:"en"`
Es string `json:"es"`
Fr string `json:"fr"`
Ja string `json:"ja"`
Ko string `json:"ko"`
Ru string `json:"ru"`
Zh string `json:"zh"`
}
type OperationName struct {
De string `json:"de"`
En string `json:"en"`
Es string `json:"es"`
Fr string `json:"fr"`
Ja string `json:"ja"`
Ko string `json:"ko"`
Ru string `json:"ru"`
Zh string `json:"zh"`
}
type StationType struct {
Key int64 `json:"_key"`
Value int64 `json:"_value"`
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 1,
"maximum": 121
},
"activityID": {
"type": "integer",
"minimum": 1,
"maximum": 20
},
"border": {
"type": "number",
"minimum": 0.0,
"maximum": 0.5
},
"corridor": {
"type": "number",
"minimum": 0.0,
"maximum": 0.5
},
"description": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 15,
"maxLength": 1193
},
"en": {
"type": "string",
"minLength": 16,
"maxLength": 1077
},
"es": {
"type": "string",
"minLength": 20,
"maxLength": 1157
},
"fr": {
"type": "string",
"minLength": 28,
"maxLength": 1153
},
"ja": {
"type": "string",
"minLength": 10,
"maxLength": 462
},
"ko": {
"type": "string",
"minLength": 8,
"maxLength": 571
},
"ru": {
"type": "string",
"minLength": 21,
"maxLength": 1140
},
"zh": {
"type": "string",
"minLength": 5,
"maxLength": 288
}
},
"required": [
"de",
"en",
"es",
"fr",
"ja",
"ko",
"ru",
"zh"
]
},
"fringe": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0
},
"hub": {
"type": "number",
"minimum": 0.0,
"maximum": 0.9
},
"manufacturingFactor": {
"type": "number",
"minimum": 0.5,
"maximum": 1.0
},
"operationName": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 3,
"maxLength": 36
},
"en": {
"type": "string",
"minLength": 5,
"maxLength": 31
},
"es": {
"type": "string",
"minLength": 6,
"maxLength": 43
},
"fr": {
"type": "string",
"minLength": 5,
"maxLength": 40
},
"ja": {
"type": "string",
"minLength": 2,
"maxLength": 15
},
"ko": {
"type": "string",
"minLength": 2,
"maxLength": 16
},
"ru": {
"type": "string",
"minLength": 7,
"maxLength": 34
},
"zh": {
"type": "string",
"minLength": 2,
"maxLength": 9
}
},
"required": [
"de",
"en",
"es",
"fr",
"ja",
"ko",
"ru",
"zh"
]
},
"ratio": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0
},
"researchFactor": {
"type": "number",
"minimum": 0.5,
"maximum": 1.0
},
"services": {
"type": "array",
"items": {
"type": "integer",
"minimum": 1,
"maximum": 27
},
"minItems": 2,
"maxItems": 24
},
"stationTypes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 1,
"maximum": 16
},
"_value": {
"type": "integer",
"minimum": 54,
"maximum": 78334
}
},
"required": [
"_key",
"_value"
]
},
"minItems": 1,
"maxItems": 5
}
},
"required": [
"_key",
"activityID",
"border",
"corridor",
"fringe",
"hub",
"manufacturingFactor",
"operationName",
"ratio",
"researchFactor",
"services"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val stationOperation = json.parse(StationOperation.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class StationOperation (
@SerialName("_key")
val key: Long,
@SerialName("activityID")
val activityId: Long,
val border: Double,
val corridor: Double,
val description: Description? = null,
val fringe: Double,
val hub: Double,
val manufacturingFactor: Double,
val operationName: OperationName,
val ratio: Double,
val researchFactor: Double,
val services: List<Long>,
val stationTypes: List<StationType>? = null
)
@Serializable
data class Description (
val de: String,
val en: String,
val es: String,
val fr: String,
val ja: String,
val ko: String,
val ru: String,
val zh: String
)
@Serializable
data class OperationName (
val de: String,
val en: String,
val es: String,
val fr: String,
val ja: String,
val ko: String,
val ru: String,
val zh: String
)
@Serializable
data class StationType (
@SerialName("_key")
val key: Long,
@SerialName("_value")
val value: Long
)
<?php
// This is a autogenerated file:StationOperation
class StationOperation {
private int $key; // json:_key Required
private int $activityId; // json:activityID Required
private float $border; // json:border Required
private float $corridor; // json:corridor Required
private ?Description $description; // json:description Optional
private float $fringe; // json:fringe Required
private float $hub; // json:hub Required
private float $manufacturingFactor; // json:manufacturingFactor Required
private OperationName $operationName; // json:operationName Required
private float $ratio; // json:ratio Required
private float $researchFactor; // json:researchFactor Required
private array $services; // json:services Required
private ?array $stationTypes; // json:stationTypes Optional
/**
* @param int $key
* @param int $activityId
* @param float $border
* @param float $corridor
* @param Description|null $description
* @param float $fringe
* @param float $hub
* @param float $manufacturingFactor
* @param OperationName $operationName
* @param float $ratio
* @param float $researchFactor
* @param array $services
* @param array|null $stationTypes
*/
public function __construct(int $key, int $activityId, float $border, float $corridor, ?Description $description, float $fringe, float $hub, float $manufacturingFactor, OperationName $operationName, float $ratio, float $researchFactor, array $services, ?array $stationTypes) {
$this->key = $key;
$this->activityId = $activityId;
$this->border = $border;
$this->corridor = $corridor;
$this->description = $description;
$this->fringe = $fringe;
$this->hub = $hub;
$this->manufacturingFactor = $manufacturingFactor;
$this->operationName = $operationName;
$this->ratio = $ratio;
$this->researchFactor = $researchFactor;
$this->services = $services;
$this->stationTypes = $stationTypes;
}
/**
* @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 (StationOperation::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this StationOperation::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:StationOperation::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (StationOperation::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey StationOperation::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromActivityId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toActivityId(): int {
if (StationOperation::validateActivityId($this->activityId)) {
return $this->activityId; /*int*/
}
throw new Exception('never get to this StationOperation::activityId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateActivityId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:StationOperation::activityId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getActivityId(): int {
if (StationOperation::validateActivityId($this->activityId)) {
return $this->activityId;
}
throw new Exception('never get to getActivityId StationOperation::activityId');
}
/**
* @return int
*/
public static function sampleActivityId(): int {
return 32; /*32:activityId*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromBorder(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toBorder(): float {
if (StationOperation::validateBorder($this->border)) {
return $this->border; /*float*/
}
throw new Exception('never get to this StationOperation::border');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateBorder(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::border");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getBorder(): float {
if (StationOperation::validateBorder($this->border)) {
return $this->border;
}
throw new Exception('never get to getBorder StationOperation::border');
}
/**
* @return float
*/
public static function sampleBorder(): float {
return 33.033; /*33:border*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromCorridor(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toCorridor(): float {
if (StationOperation::validateCorridor($this->corridor)) {
return $this->corridor; /*float*/
}
throw new Exception('never get to this StationOperation::corridor');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateCorridor(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::corridor");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getCorridor(): float {
if (StationOperation::validateCorridor($this->corridor)) {
return $this->corridor;
}
throw new Exception('never get to getCorridor StationOperation::corridor');
}
/**
* @return float
*/
public static function sampleCorridor(): float {
return 34.034; /*34:corridor*/
}
/**
* @param ?stdClass $value
* @throws Exception
* @return ?Description
*/
public static function fromDescription(?stdClass $value): ?Description {
if (!is_null($value)) {
return Description::from($value); /*class*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?stdClass
*/
public function toDescription(): ?stdClass {
if (StationOperation::validateDescription($this->description)) {
if (!is_null($this->description)) {
return $this->description->to(); /*class*/
} else {
return null;
}
}
throw new Exception('never get to this StationOperation::description');
}
/**
* @param Description|null
* @return bool
* @throws Exception
*/
public static function validateDescription(?Description $value): bool {
if (!is_null($value)) {
$value->validate();
}
return true;
}
/**
* @throws Exception
* @return ?Description
*/
public function getDescription(): ?Description {
if (StationOperation::validateDescription($this->description)) {
return $this->description;
}
throw new Exception('never get to getDescription StationOperation::description');
}
/**
* @return ?Description
*/
public static function sampleDescription(): ?Description {
return Description::sample(); /*35:description*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromFringe(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toFringe(): float {
if (StationOperation::validateFringe($this->fringe)) {
return $this->fringe; /*float*/
}
throw new Exception('never get to this StationOperation::fringe');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateFringe(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::fringe");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getFringe(): float {
if (StationOperation::validateFringe($this->fringe)) {
return $this->fringe;
}
throw new Exception('never get to getFringe StationOperation::fringe');
}
/**
* @return float
*/
public static function sampleFringe(): float {
return 36.036; /*36:fringe*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromHub(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toHub(): float {
if (StationOperation::validateHub($this->hub)) {
return $this->hub; /*float*/
}
throw new Exception('never get to this StationOperation::hub');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateHub(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::hub");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getHub(): float {
if (StationOperation::validateHub($this->hub)) {
return $this->hub;
}
throw new Exception('never get to getHub StationOperation::hub');
}
/**
* @return float
*/
public static function sampleHub(): float {
return 37.037; /*37:hub*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromManufacturingFactor(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toManufacturingFactor(): float {
if (StationOperation::validateManufacturingFactor($this->manufacturingFactor)) {
return $this->manufacturingFactor; /*float*/
}
throw new Exception('never get to this StationOperation::manufacturingFactor');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateManufacturingFactor(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::manufacturingFactor");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getManufacturingFactor(): float {
if (StationOperation::validateManufacturingFactor($this->manufacturingFactor)) {
return $this->manufacturingFactor;
}
throw new Exception('never get to getManufacturingFactor StationOperation::manufacturingFactor');
}
/**
* @return float
*/
public static function sampleManufacturingFactor(): float {
return 38.038; /*38:manufacturingFactor*/
}
/**
* @param stdClass $value
* @throws Exception
* @return OperationName
*/
public static function fromOperationName(stdClass $value): OperationName {
return OperationName::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toOperationName(): stdClass {
if (StationOperation::validateOperationName($this->operationName)) {
return $this->operationName->to(); /*class*/
}
throw new Exception('never get to this StationOperation::operationName');
}
/**
* @param OperationName
* @return bool
* @throws Exception
*/
public static function validateOperationName(OperationName $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return OperationName
*/
public function getOperationName(): OperationName {
if (StationOperation::validateOperationName($this->operationName)) {
return $this->operationName;
}
throw new Exception('never get to getOperationName StationOperation::operationName');
}
/**
* @return OperationName
*/
public static function sampleOperationName(): OperationName {
return OperationName::sample(); /*39:operationName*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromRatio(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toRatio(): float {
if (StationOperation::validateRatio($this->ratio)) {
return $this->ratio; /*float*/
}
throw new Exception('never get to this StationOperation::ratio');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateRatio(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::ratio");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getRatio(): float {
if (StationOperation::validateRatio($this->ratio)) {
return $this->ratio;
}
throw new Exception('never get to getRatio StationOperation::ratio');
}
/**
* @return float
*/
public static function sampleRatio(): float {
return 40.04; /*40:ratio*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromResearchFactor(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toResearchFactor(): float {
if (StationOperation::validateResearchFactor($this->researchFactor)) {
return $this->researchFactor; /*float*/
}
throw new Exception('never get to this StationOperation::researchFactor');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateResearchFactor(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:StationOperation::researchFactor");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getResearchFactor(): float {
if (StationOperation::validateResearchFactor($this->researchFactor)) {
return $this->researchFactor;
}
throw new Exception('never get to getResearchFactor StationOperation::researchFactor');
}
/**
* @return float
*/
public static function sampleResearchFactor(): float {
return 41.041; /*41:researchFactor*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromServices(array $value): array {
return array_map(function ($value) {
return $value; /*int*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toServices(): array {
if (StationOperation::validateServices($this->services)) {
return array_map(function ($value) {
return $value; /*int*/
}, $this->services);
}
throw new Exception('never get to this StationOperation::services');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateServices(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:StationOperation::services");
}
array_walk($value, function($value_v) {
if (!is_integer($value_v)) {
throw new Exception("Attribute Error:StationOperation::services");
}
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getServices(): array {
if (StationOperation::validateServices($this->services)) {
return $this->services;
}
throw new Exception('never get to getServices StationOperation::services');
}
/**
* @return array
*/
public static function sampleServices(): array {
return array(
42 /*42:*/
); /* 42:services*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromStationTypes(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return StationType::from($value); /*class*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toStationTypes(): ?array {
if (StationOperation::validateStationTypes($this->stationTypes)) {
if (!is_null($this->stationTypes)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->stationTypes);
} else {
return null;
}
}
throw new Exception('never get to this StationOperation::stationTypes');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateStationTypes(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:StationOperation::stationTypes");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getStationTypes(): ?array {
if (StationOperation::validateStationTypes($this->stationTypes)) {
return $this->stationTypes;
}
throw new Exception('never get to getStationTypes StationOperation::stationTypes');
}
/**
* @return ?array
*/
public static function sampleStationTypes(): ?array {
return array(
StationType::sample() /*43:*/
); /* 43:stationTypes*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return StationOperation::validateKey($this->key)
|| StationOperation::validateActivityId($this->activityId)
|| StationOperation::validateBorder($this->border)
|| StationOperation::validateCorridor($this->corridor)
|| StationOperation::validateDescription($this->description)
|| StationOperation::validateFringe($this->fringe)
|| StationOperation::validateHub($this->hub)
|| StationOperation::validateManufacturingFactor($this->manufacturingFactor)
|| StationOperation::validateOperationName($this->operationName)
|| StationOperation::validateRatio($this->ratio)
|| StationOperation::validateResearchFactor($this->researchFactor)
|| StationOperation::validateServices($this->services)
|| StationOperation::validateStationTypes($this->stationTypes);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'activityID'} = $this->toActivityId();
$out->{'border'} = $this->toBorder();
$out->{'corridor'} = $this->toCorridor();
$out->{'description'} = $this->toDescription();
$out->{'fringe'} = $this->toFringe();
$out->{'hub'} = $this->toHub();
$out->{'manufacturingFactor'} = $this->toManufacturingFactor();
$out->{'operationName'} = $this->toOperationName();
$out->{'ratio'} = $this->toRatio();
$out->{'researchFactor'} = $this->toResearchFactor();
$out->{'services'} = $this->toServices();
$out->{'stationTypes'} = $this->toStationTypes();
return $out;
}
/**
* @param stdClass $obj
* @return StationOperation
* @throws Exception
*/
public static function from(stdClass $obj): StationOperation {
return new StationOperation(
StationOperation::fromKey($obj->{'_key'})
,StationOperation::fromActivityId($obj->{'activityID'})
,StationOperation::fromBorder($obj->{'border'})
,StationOperation::fromCorridor($obj->{'corridor'})
,StationOperation::fromDescription($obj->{'description'})
,StationOperation::fromFringe($obj->{'fringe'})
,StationOperation::fromHub($obj->{'hub'})
,StationOperation::fromManufacturingFactor($obj->{'manufacturingFactor'})
,StationOperation::fromOperationName($obj->{'operationName'})
,StationOperation::fromRatio($obj->{'ratio'})
,StationOperation::fromResearchFactor($obj->{'researchFactor'})
,StationOperation::fromServices($obj->{'services'})
,StationOperation::fromStationTypes($obj->{'stationTypes'})
);
}
/**
* @return StationOperation
*/
public static function sample(): StationOperation {
return new StationOperation(
StationOperation::sampleKey()
,StationOperation::sampleActivityId()
,StationOperation::sampleBorder()
,StationOperation::sampleCorridor()
,StationOperation::sampleDescription()
,StationOperation::sampleFringe()
,StationOperation::sampleHub()
,StationOperation::sampleManufacturingFactor()
,StationOperation::sampleOperationName()
,StationOperation::sampleRatio()
,StationOperation::sampleResearchFactor()
,StationOperation::sampleServices()
,StationOperation::sampleStationTypes()
);
}
}
// This is a autogenerated file:Description
class Description {
private string $de; // json:de Required
private string $en; // json:en Required
private string $es; // json:es Required
private string $fr; // json:fr Required
private string $ja; // json:ja Required
private string $ko; // json:ko Required
private string $ru; // json:ru Required
private string $zh; // json:zh Required
/**
* @param string $de
* @param string $en
* @param string $es
* @param string $fr
* @param string $ja
* @param string $ko
* @param string $ru
* @param string $zh
*/
public function __construct(string $de, string $en, string $es, string $fr, string $ja, string $ko, string $ru, string $zh) {
$this->de = $de;
$this->en = $en;
$this->es = $es;
$this->fr = $fr;
$this->ja = $ja;
$this->ko = $ko;
$this->ru = $ru;
$this->zh = $zh;
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromDe(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toDe(): string {
if (Description::validateDe($this->de)) {
return $this->de; /*string*/
}
throw new Exception('never get to this Description::de');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateDe(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::de");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getDe(): string {
if (Description::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe Description::de');
}
/**
* @return string
*/
public static function sampleDe(): string {
return 'Description::de::31'; /*31:de*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEn(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEn(): string {
if (Description::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this Description::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (Description::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn Description::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'Description::en::32'; /*32:en*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEs(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEs(): string {
if (Description::validateEs($this->es)) {
return $this->es; /*string*/
}
throw new Exception('never get to this Description::es');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEs(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::es");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEs(): string {
if (Description::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs Description::es');
}
/**
* @return string
*/
public static function sampleEs(): string {
return 'Description::es::33'; /*33:es*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromFr(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toFr(): string {
if (Description::validateFr($this->fr)) {
return $this->fr; /*string*/
}
throw new Exception('never get to this Description::fr');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateFr(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::fr");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getFr(): string {
if (Description::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr Description::fr');
}
/**
* @return string
*/
public static function sampleFr(): string {
return 'Description::fr::34'; /*34:fr*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromJa(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toJa(): string {
if (Description::validateJa($this->ja)) {
return $this->ja; /*string*/
}
throw new Exception('never get to this Description::ja');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateJa(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::ja");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getJa(): string {
if (Description::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa Description::ja');
}
/**
* @return string
*/
public static function sampleJa(): string {
return 'Description::ja::35'; /*35:ja*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromKo(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toKo(): string {
if (Description::validateKo($this->ko)) {
return $this->ko; /*string*/
}
throw new Exception('never get to this Description::ko');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateKo(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::ko");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getKo(): string {
if (Description::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo Description::ko');
}
/**
* @return string
*/
public static function sampleKo(): string {
return 'Description::ko::36'; /*36:ko*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromRu(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toRu(): string {
if (Description::validateRu($this->ru)) {
return $this->ru; /*string*/
}
throw new Exception('never get to this Description::ru');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateRu(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::ru");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getRu(): string {
if (Description::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu Description::ru');
}
/**
* @return string
*/
public static function sampleRu(): string {
return 'Description::ru::37'; /*37:ru*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromZh(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toZh(): string {
if (Description::validateZh($this->zh)) {
return $this->zh; /*string*/
}
throw new Exception('never get to this Description::zh');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateZh(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Description::zh");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getZh(): string {
if (Description::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh Description::zh');
}
/**
* @return string
*/
public static function sampleZh(): string {
return 'Description::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Description::validateDe($this->de)
|| Description::validateEn($this->en)
|| Description::validateEs($this->es)
|| Description::validateFr($this->fr)
|| Description::validateJa($this->ja)
|| Description::validateKo($this->ko)
|| Description::validateRu($this->ru)
|| Description::validateZh($this->zh);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'de'} = $this->toDe();
$out->{'en'} = $this->toEn();
$out->{'es'} = $this->toEs();
$out->{'fr'} = $this->toFr();
$out->{'ja'} = $this->toJa();
$out->{'ko'} = $this->toKo();
$out->{'ru'} = $this->toRu();
$out->{'zh'} = $this->toZh();
return $out;
}
/**
* @param stdClass $obj
* @return Description
* @throws Exception
*/
public static function from(stdClass $obj): Description {
return new Description(
Description::fromDe($obj->{'de'})
,Description::fromEn($obj->{'en'})
,Description::fromEs($obj->{'es'})
,Description::fromFr($obj->{'fr'})
,Description::fromJa($obj->{'ja'})
,Description::fromKo($obj->{'ko'})
,Description::fromRu($obj->{'ru'})
,Description::fromZh($obj->{'zh'})
);
}
/**
* @return Description
*/
public static function sample(): Description {
return new Description(
Description::sampleDe()
,Description::sampleEn()
,Description::sampleEs()
,Description::sampleFr()
,Description::sampleJa()
,Description::sampleKo()
,Description::sampleRu()
,Description::sampleZh()
);
}
}
// This is a autogenerated file:OperationName
class OperationName {
private string $de; // json:de Required
private string $en; // json:en Required
private string $es; // json:es Required
private string $fr; // json:fr Required
private string $ja; // json:ja Required
private string $ko; // json:ko Required
private string $ru; // json:ru Required
private string $zh; // json:zh Required
/**
* @param string $de
* @param string $en
* @param string $es
* @param string $fr
* @param string $ja
* @param string $ko
* @param string $ru
* @param string $zh
*/
public function __construct(string $de, string $en, string $es, string $fr, string $ja, string $ko, string $ru, string $zh) {
$this->de = $de;
$this->en = $en;
$this->es = $es;
$this->fr = $fr;
$this->ja = $ja;
$this->ko = $ko;
$this->ru = $ru;
$this->zh = $zh;
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromDe(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toDe(): string {
if (OperationName::validateDe($this->de)) {
return $this->de; /*string*/
}
throw new Exception('never get to this OperationName::de');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateDe(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::de");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getDe(): string {
if (OperationName::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe OperationName::de');
}
/**
* @return string
*/
public static function sampleDe(): string {
return 'OperationName::de::31'; /*31:de*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEn(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEn(): string {
if (OperationName::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this OperationName::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (OperationName::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn OperationName::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'OperationName::en::32'; /*32:en*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEs(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEs(): string {
if (OperationName::validateEs($this->es)) {
return $this->es; /*string*/
}
throw new Exception('never get to this OperationName::es');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEs(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::es");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEs(): string {
if (OperationName::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs OperationName::es');
}
/**
* @return string
*/
public static function sampleEs(): string {
return 'OperationName::es::33'; /*33:es*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromFr(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toFr(): string {
if (OperationName::validateFr($this->fr)) {
return $this->fr; /*string*/
}
throw new Exception('never get to this OperationName::fr');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateFr(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::fr");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getFr(): string {
if (OperationName::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr OperationName::fr');
}
/**
* @return string
*/
public static function sampleFr(): string {
return 'OperationName::fr::34'; /*34:fr*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromJa(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toJa(): string {
if (OperationName::validateJa($this->ja)) {
return $this->ja; /*string*/
}
throw new Exception('never get to this OperationName::ja');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateJa(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::ja");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getJa(): string {
if (OperationName::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa OperationName::ja');
}
/**
* @return string
*/
public static function sampleJa(): string {
return 'OperationName::ja::35'; /*35:ja*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromKo(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toKo(): string {
if (OperationName::validateKo($this->ko)) {
return $this->ko; /*string*/
}
throw new Exception('never get to this OperationName::ko');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateKo(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::ko");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getKo(): string {
if (OperationName::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo OperationName::ko');
}
/**
* @return string
*/
public static function sampleKo(): string {
return 'OperationName::ko::36'; /*36:ko*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromRu(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toRu(): string {
if (OperationName::validateRu($this->ru)) {
return $this->ru; /*string*/
}
throw new Exception('never get to this OperationName::ru');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateRu(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::ru");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getRu(): string {
if (OperationName::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu OperationName::ru');
}
/**
* @return string
*/
public static function sampleRu(): string {
return 'OperationName::ru::37'; /*37:ru*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromZh(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toZh(): string {
if (OperationName::validateZh($this->zh)) {
return $this->zh; /*string*/
}
throw new Exception('never get to this OperationName::zh');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateZh(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:OperationName::zh");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getZh(): string {
if (OperationName::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh OperationName::zh');
}
/**
* @return string
*/
public static function sampleZh(): string {
return 'OperationName::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return OperationName::validateDe($this->de)
|| OperationName::validateEn($this->en)
|| OperationName::validateEs($this->es)
|| OperationName::validateFr($this->fr)
|| OperationName::validateJa($this->ja)
|| OperationName::validateKo($this->ko)
|| OperationName::validateRu($this->ru)
|| OperationName::validateZh($this->zh);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'de'} = $this->toDe();
$out->{'en'} = $this->toEn();
$out->{'es'} = $this->toEs();
$out->{'fr'} = $this->toFr();
$out->{'ja'} = $this->toJa();
$out->{'ko'} = $this->toKo();
$out->{'ru'} = $this->toRu();
$out->{'zh'} = $this->toZh();
return $out;
}
/**
* @param stdClass $obj
* @return OperationName
* @throws Exception
*/
public static function from(stdClass $obj): OperationName {
return new OperationName(
OperationName::fromDe($obj->{'de'})
,OperationName::fromEn($obj->{'en'})
,OperationName::fromEs($obj->{'es'})
,OperationName::fromFr($obj->{'fr'})
,OperationName::fromJa($obj->{'ja'})
,OperationName::fromKo($obj->{'ko'})
,OperationName::fromRu($obj->{'ru'})
,OperationName::fromZh($obj->{'zh'})
);
}
/**
* @return OperationName
*/
public static function sample(): OperationName {
return new OperationName(
OperationName::sampleDe()
,OperationName::sampleEn()
,OperationName::sampleEs()
,OperationName::sampleFr()
,OperationName::sampleJa()
,OperationName::sampleKo()
,OperationName::sampleRu()
,OperationName::sampleZh()
);
}
}
// This is a autogenerated file:StationType
class StationType {
private int $key; // json:_key Required
private int $value; // json:_value Required
/**
* @param int $key
* @param int $value
*/
public function __construct(int $key, int $value) {
$this->key = $key;
$this->value = $value;
}
/**
* @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 (StationType::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this StationType::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:StationType::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (StationType::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey StationType::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromValue(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toValue(): int {
if (StationType::validateValue($this->value)) {
return $this->value; /*int*/
}
throw new Exception('never get to this StationType::value');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateValue(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:StationType::value");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getValue(): int {
if (StationType::validateValue($this->value)) {
return $this->value;
}
throw new Exception('never get to getValue StationType::value');
}
/**
* @return int
*/
public static function sampleValue(): int {
return 32; /*32:value*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return StationType::validateKey($this->key)
|| StationType::validateValue($this->value);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'_value'} = $this->toValue();
return $out;
}
/**
* @param stdClass $obj
* @return StationType
* @throws Exception
*/
public static function from(stdClass $obj): StationType {
return new StationType(
StationType::fromKey($obj->{'_key'})
,StationType::fromValue($obj->{'_value'})
);
}
/**
* @return StationType
*/
public static function sample(): StationType {
return new StationType(
StationType::sampleKey()
,StationType::sampleValue()
);
}
}
from typing import Any, Optional, List, TypeVar, Callable, Type, cast
T = TypeVar("T")
def from_str(x: Any) -> str:
assert isinstance(x, str)
return x
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_float(x: Any) -> float:
assert isinstance(x, (float, int)) and not isinstance(x, bool)
return float(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_float(x: Any) -> float:
assert isinstance(x, (int, float))
return x
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class Description:
de: str
en: str
es: str
fr: str
ja: str
ko: str
ru: str
zh: str
def __init__(self, de: str, en: str, es: str, fr: str, ja: str, ko: str, ru: str, zh: str) -> None:
self.de = de
self.en = en
self.es = es
self.fr = fr
self.ja = ja
self.ko = ko
self.ru = ru
self.zh = zh
@staticmethod
def from_dict(obj: Any) -> 'Description':
assert isinstance(obj, dict)
de = from_str(obj.get("de"))
en = from_str(obj.get("en"))
es = from_str(obj.get("es"))
fr = from_str(obj.get("fr"))
ja = from_str(obj.get("ja"))
ko = from_str(obj.get("ko"))
ru = from_str(obj.get("ru"))
zh = from_str(obj.get("zh"))
return Description(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
result["de"] = from_str(self.de)
result["en"] = from_str(self.en)
result["es"] = from_str(self.es)
result["fr"] = from_str(self.fr)
result["ja"] = from_str(self.ja)
result["ko"] = from_str(self.ko)
result["ru"] = from_str(self.ru)
result["zh"] = from_str(self.zh)
return result
class OperationName:
de: str
en: str
es: str
fr: str
ja: str
ko: str
ru: str
zh: str
def __init__(self, de: str, en: str, es: str, fr: str, ja: str, ko: str, ru: str, zh: str) -> None:
self.de = de
self.en = en
self.es = es
self.fr = fr
self.ja = ja
self.ko = ko
self.ru = ru
self.zh = zh
@staticmethod
def from_dict(obj: Any) -> 'OperationName':
assert isinstance(obj, dict)
de = from_str(obj.get("de"))
en = from_str(obj.get("en"))
es = from_str(obj.get("es"))
fr = from_str(obj.get("fr"))
ja = from_str(obj.get("ja"))
ko = from_str(obj.get("ko"))
ru = from_str(obj.get("ru"))
zh = from_str(obj.get("zh"))
return OperationName(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
result["de"] = from_str(self.de)
result["en"] = from_str(self.en)
result["es"] = from_str(self.es)
result["fr"] = from_str(self.fr)
result["ja"] = from_str(self.ja)
result["ko"] = from_str(self.ko)
result["ru"] = from_str(self.ru)
result["zh"] = from_str(self.zh)
return result
class StationType:
key: int
value: int
def __init__(self, key: int, value: int) -> None:
self.key = key
self.value = value
@staticmethod
def from_dict(obj: Any) -> 'StationType':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
value = from_int(obj.get("_value"))
return StationType(key, value)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["_value"] = from_int(self.value)
return result
class StationOperation:
key: int
activity_id: int
border: float
corridor: float
description: Optional[Description]
fringe: float
hub: float
manufacturing_factor: float
operation_name: OperationName
ratio: float
research_factor: float
services: List[int]
station_types: Optional[List[StationType]]
def __init__(self, key: int, activity_id: int, border: float, corridor: float, description: Optional[Description], fringe: float, hub: float, manufacturing_factor: float, operation_name: OperationName, ratio: float, research_factor: float, services: List[int], station_types: Optional[List[StationType]]) -> None:
self.key = key
self.activity_id = activity_id
self.border = border
self.corridor = corridor
self.description = description
self.fringe = fringe
self.hub = hub
self.manufacturing_factor = manufacturing_factor
self.operation_name = operation_name
self.ratio = ratio
self.research_factor = research_factor
self.services = services
self.station_types = station_types
@staticmethod
def from_dict(obj: Any) -> 'StationOperation':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
activity_id = from_int(obj.get("activityID"))
border = from_float(obj.get("border"))
corridor = from_float(obj.get("corridor"))
description = from_union([Description.from_dict, from_none], obj.get("description"))
fringe = from_float(obj.get("fringe"))
hub = from_float(obj.get("hub"))
manufacturing_factor = from_float(obj.get("manufacturingFactor"))
operation_name = OperationName.from_dict(obj.get("operationName"))
ratio = from_float(obj.get("ratio"))
research_factor = from_float(obj.get("researchFactor"))
services = from_list(from_int, obj.get("services"))
station_types = from_union([lambda x: from_list(StationType.from_dict, x), from_none], obj.get("stationTypes"))
return StationOperation(key, activity_id, border, corridor, description, fringe, hub, manufacturing_factor, operation_name, ratio, research_factor, services, station_types)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["activityID"] = from_int(self.activity_id)
result["border"] = to_float(self.border)
result["corridor"] = to_float(self.corridor)
if self.description is not None:
result["description"] = from_union([lambda x: to_class(Description, x), from_none], self.description)
result["fringe"] = to_float(self.fringe)
result["hub"] = to_float(self.hub)
result["manufacturingFactor"] = to_float(self.manufacturing_factor)
result["operationName"] = to_class(OperationName, self.operation_name)
result["ratio"] = to_float(self.ratio)
result["researchFactor"] = to_float(self.research_factor)
result["services"] = from_list(from_int, self.services)
if self.station_types is not None:
result["stationTypes"] = from_union([lambda x: from_list(lambda x: to_class(StationType, x), x), from_none], self.station_types)
return result
def station_operation_from_dict(s: Any) -> StationOperation:
return StationOperation.from_dict(s)
def station_operation_to_dict(x: StationOperation) -> Any:
return to_class(StationOperation, x)
// To parse this data:
//
// import { Convert, StationOperation } from "./file";
//
// const stationOperation = Convert.toStationOperation(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface StationOperation {
_key: number;
activityID: number;
border: number;
corridor: number;
description?: Description;
fringe: number;
hub: number;
manufacturingFactor: number;
operationName: OperationName;
ratio: number;
researchFactor: number;
services: number[];
stationTypes?: StationType[];
[property: string]: any;
}
export interface Description {
de: string;
en: string;
es: string;
fr: string;
ja: string;
ko: string;
ru: string;
zh: string;
[property: string]: any;
}
export interface OperationName {
de: string;
en: string;
es: string;
fr: string;
ja: string;
ko: string;
ru: string;
zh: string;
[property: string]: any;
}
export interface StationType {
_key: number;
_value: 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 toStationOperation(json: string): StationOperation {
return cast(JSON.parse(json), r("StationOperation"));
}
public static stationOperationToJson(value: StationOperation): string {
return JSON.stringify(uncast(value, r("StationOperation")), 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 = {
"StationOperation": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "activityID", js: "activityID", typ: 0 },
{ json: "border", js: "border", typ: 3.14 },
{ json: "corridor", js: "corridor", typ: 3.14 },
{ json: "description", js: "description", typ: u(undefined, r("Description")) },
{ json: "fringe", js: "fringe", typ: 3.14 },
{ json: "hub", js: "hub", typ: 3.14 },
{ json: "manufacturingFactor", js: "manufacturingFactor", typ: 3.14 },
{ json: "operationName", js: "operationName", typ: r("OperationName") },
{ json: "ratio", js: "ratio", typ: 3.14 },
{ json: "researchFactor", js: "researchFactor", typ: 3.14 },
{ json: "services", js: "services", typ: a(0) },
{ json: "stationTypes", js: "stationTypes", typ: u(undefined, a(r("StationType"))) },
], "any"),
"Description": o([
{ json: "de", js: "de", typ: "" },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: "" },
{ json: "fr", js: "fr", typ: "" },
{ json: "ja", js: "ja", typ: "" },
{ json: "ko", js: "ko", typ: "" },
{ json: "ru", js: "ru", typ: "" },
{ json: "zh", js: "zh", typ: "" },
], "any"),
"OperationName": o([
{ json: "de", js: "de", typ: "" },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: "" },
{ json: "fr", js: "fr", typ: "" },
{ json: "ja", js: "ja", typ: "" },
{ json: "ko", js: "ko", typ: "" },
{ json: "ru", js: "ru", typ: "" },
{ json: "zh", js: "zh", typ: "" },
], "any"),
"StationType": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "_value", js: "_value", typ: 0 },
], "any"),
};