Skip to content

Instantly share code, notes, and snippets.

@plokhotnyuk
Last active May 4, 2018 09:55
Show Gist options
  • Save plokhotnyuk/eb3b3cc53ee84219079746ac9da15784 to your computer and use it in GitHub Desktop.
Save plokhotnyuk/eb3b3cc53ee84219079746ac9da15784 to your computer and use it in GitHub Desktop.
[info] final class $anon extends JsonValueCodec[com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root] {
[info] def nullValue: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root = null;
[info] def decodeValue(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root = d0(in, default);
[info] def encodeValue(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root, out: JsonWriter): Unit = e0(x, out);
[info] private[this] val r0: Array[String] = Array("$schema", "type");
[info] private[this] val r1: Array[String] = Array("type");
[info] private[this] val r2: Array[String] = Array("type");
[info] private[this] val r3: Array[String] = Array("type", "items");
[info] private[this] val r4: Array[String] = Array("type");
[info] private[this] def d4(in: JsonReader, default: Option[String]): Option[String] = if (in.isNextToken('n'))
[info] in.readNullOrError(default, "expected value or null")
[info] else
[info] {
[info] in.rollbackToken();
[info] Some(in.readString(null))
[info] };
[info] private[this] def d3(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.BasicProperty): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.BasicProperty = if (in.isNextToken('{'))
[info] {
[info] var _type: String = null;
[info] var _format: Option[String] = BasicProperty.`<init>$default$2`;
[info] var p0 = 3;
[info] var pd = true;
[info] if (in.isNextToken('}').`unary_!`)
[info] {
[info] in.rollbackToken();
[info] do
[info] {
[info] val l = in.readKeyAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case 3575610 => if (in.isCharBufEqualsTo(l, "type"))
[info] {
[info] if (p0.&(1).!=(0))
[info] p0.^=(1)
[info] else
[info] in.duplicatedKeyError(l);
[info] _type = in.readString(_type)
[info] }
[info] else
[info] in.skip()
[info] case -1268779017 => if (in.isCharBufEqualsTo(l, "format"))
[info] {
[info] if (p0.&(2).!=(0))
[info] p0.^=(2)
[info] else
[info] in.duplicatedKeyError(l);
[info] _format = d4(in, _format)
[info] }
[info] else
[info] in.skip()
[info] case 115339 => if (pd)
[info] {
[info] pd = pd.`unary_!`;
[info] in.skip()
[info] }
[info] else
[info] in.duplicatedKeyError(l)
[info] case _ => in.skip()
[info] }
[info] }
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}').`unary_!`)
[info] in.objectEndOrCommaError()
[info] else
[info] ()
[info] }
[info] else
[info] ();
[info] if (p0.&(1).!=(0))
[info] in.requiredFieldError(r1(Integer.numberOfTrailingZeros(p0)))
[info] else
[info] ();
[info] new com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.BasicProperty(`type` = _type, format = _format)
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def d6(in: JsonReader, default: List[String]): List[String] = if (in.isNextToken('['))
[info] if (in.isNextToken(']'))
[info] default
[info] else
[info] {
[info] in.rollbackToken();
[info] val x = List.newBuilder[String];
[info] do
[info] x.+=(in.readString(null))
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken(']'))
[info] x.result()
[info] else
[info] in.arrayEndOrCommaError()
[info] }
[info] else
[info] in.readNullOrTokenError(default, '[');
[info] private[this] def d5(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.EnumProperty): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.EnumProperty = if (in.isNextToken('{'))
[info] {
[info] var _type: String = null;
[info] var _enum: List[String] = List.empty[String];
[info] var p0 = 3;
[info] var pd = true;
[info] if (in.isNextToken('}').`unary_!`)
[info] {
[info] in.rollbackToken();
[info] do
[info] {
[info] val l = in.readKeyAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case 3575610 => if (in.isCharBufEqualsTo(l, "type"))
[info] {
[info] if (p0.&(1).!=(0))
[info] p0.^=(1)
[info] else
[info] in.duplicatedKeyError(l);
[info] _type = in.readString(_type)
[info] }
[info] else
[info] in.skip()
[info] case 3118337 => if (in.isCharBufEqualsTo(l, "enum"))
[info] {
[info] if (p0.&(2).!=(0))
[info] p0.^=(2)
[info] else
[info] in.duplicatedKeyError(l);
[info] _enum = d6(in, _enum)
[info] }
[info] else
[info] in.skip()
[info] case 115339 => if (pd)
[info] {
[info] pd = pd.`unary_!`;
[info] in.skip()
[info] }
[info] else
[info] in.duplicatedKeyError(l)
[info] case _ => in.skip()
[info] }
[info] }
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}').`unary_!`)
[info] in.objectEndOrCommaError()
[info] else
[info] ()
[info] }
[info] else
[info] ();
[info] if (p0.&(1).!=(0))
[info] in.requiredFieldError(r2(Integer.numberOfTrailingZeros(p0)))
[info] else
[info] ();
[info] new com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.EnumProperty(`type` = _type, enum = _enum)
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def d7(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ArrayProperty): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ArrayProperty = if (in.isNextToken('{'))
[info] {
[info] var _type: String = null;
[info] var _items: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property = null;
[info] var p0 = 3;
[info] var pd = true;
[info] if (in.isNextToken('}').`unary_!`)
[info] {
[info] in.rollbackToken();
[info] do
[info] {
[info] val l = in.readKeyAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case 3575610 => if (in.isCharBufEqualsTo(l, "type"))
[info] {
[info] if (p0.&(1).!=(0))
[info] p0.^=(1)
[info] else
[info] in.duplicatedKeyError(l);
[info] _type = in.readString(_type)
[info] }
[info] else
[info] in.skip()
[info] case 100526016 => if (in.isCharBufEqualsTo(l, "items"))
[info] {
[info] if (p0.&(2).!=(0))
[info] p0.^=(2)
[info] else
[info] in.duplicatedKeyError(l);
[info] _items = d2(in, _items)
[info] }
[info] else
[info] in.skip()
[info] case 115339 => if (pd)
[info] {
[info] pd = pd.`unary_!`;
[info] in.skip()
[info] }
[info] else
[info] in.duplicatedKeyError(l)
[info] case _ => in.skip()
[info] }
[info] }
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}').`unary_!`)
[info] in.objectEndOrCommaError()
[info] else
[info] ()
[info] }
[info] else
[info] ();
[info] if (p0.&(3).!=(0))
[info] in.requiredFieldError(r3(Integer.numberOfTrailingZeros(p0)))
[info] else
[info] ();
[info] new com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ArrayProperty(`type` = _type, items = _items)
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def d8(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ComplexProperty): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ComplexProperty = if (in.isNextToken('{'))
[info] {
[info] var _type: String = null;
[info] var _properties: scala.collection.immutable.Map[String,com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property] = Map.empty[String, com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property];
[info] var _format: Option[String] = ComplexProperty.`<init>$default$3`;
[info] var _required: List[String] = ComplexProperty.`<init>$default$4`;
[info] var p0 = 15;
[info] var pd = true;
[info] if (in.isNextToken('}').`unary_!`)
[info] {
[info] in.rollbackToken();
[info] do
[info] {
[info] val l = in.readKeyAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case 3575610 => if (in.isCharBufEqualsTo(l, "type"))
[info] {
[info] if (p0.&(1).!=(0))
[info] p0.^=(1)
[info] else
[info] in.duplicatedKeyError(l);
[info] _type = in.readString(_type)
[info] }
[info] else
[info] in.skip()
[info] case -926053069 => if (in.isCharBufEqualsTo(l, "properties"))
[info] {
[info] if (p0.&(2).!=(0))
[info] p0.^=(2)
[info] else
[info] in.duplicatedKeyError(l);
[info] _properties = d1(in, _properties)
[info] }
[info] else
[info] in.skip()
[info] case -1268779017 => if (in.isCharBufEqualsTo(l, "format"))
[info] {
[info] if (p0.&(4).!=(0))
[info] p0.^=(4)
[info] else
[info] in.duplicatedKeyError(l);
[info] _format = d4(in, _format)
[info] }
[info] else
[info] in.skip()
[info] case -393139297 => if (in.isCharBufEqualsTo(l, "required"))
[info] {
[info] if (p0.&(8).!=(0))
[info] p0.^=(8)
[info] else
[info] in.duplicatedKeyError(l);
[info] _required = d6(in, _required)
[info] }
[info] else
[info] in.skip()
[info] case 115339 => if (pd)
[info] {
[info] pd = pd.`unary_!`;
[info] in.skip()
[info] }
[info] else
[info] in.duplicatedKeyError(l)
[info] case _ => in.skip()
[info] }
[info] }
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}').`unary_!`)
[info] in.objectEndOrCommaError()
[info] else
[info] ()
[info] }
[info] else
[info] ();
[info] if (p0.&(1).!=(0))
[info] in.requiredFieldError(r4(Integer.numberOfTrailingZeros(p0)))
[info] else
[info] ();
[info] new com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ComplexProperty(`type` = _type, properties = _properties, format = _format, required = _required)
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def d2(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property = {
[info] in.setMark();
[info] if (in.isNextToken('{'))
[info] if (in.skipToKey("typ"))
[info] {
[info] val l = in.readStringAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case -1676527613 => if (in.isCharBufEqualsTo(l, "BasicProperty"))
[info] {
[info] in.rollbackToMark();
[info] d3(in, null)
[info] }
[info] else
[info] in.discriminatorValueError("typ")
[info] case 2553090 => if (in.isCharBufEqualsTo(l, "Root"))
[info] {
[info] in.rollbackToMark();
[info] JsonSchema.this.RootCodec.decodeValue(in, null)
[info] }
[info] else
[info] in.discriminatorValueError("typ")
[info] case -1669162474 => if (in.isCharBufEqualsTo(l, "EnumProperty"))
[info] {
[info] in.rollbackToMark();
[info] d5(in, null)
[info] }
[info] else
[info] in.discriminatorValueError("typ")
[info] case -1223918802 => if (in.isCharBufEqualsTo(l, "ArrayProperty"))
[info] {
[info] in.rollbackToMark();
[info] d7(in, null)
[info] }
[info] else
[info] in.discriminatorValueError("typ")
[info] case -649417083 => if (in.isCharBufEqualsTo(l, "ComplexProperty"))
[info] {
[info] in.rollbackToMark();
[info] d8(in, null)
[info] }
[info] else
[info] in.discriminatorValueError("typ")
[info] case _ => in.discriminatorValueError("typ")
[info] }
[info] }
[info] else
[info] in.requiredFieldError("typ")
[info] else
[info] in.readNullOrTokenError(default, '{')
[info] };
[info] private[this] def d1(in: JsonReader, default: scala.collection.immutable.Map[String,com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property]): scala.collection.immutable.Map[String,com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property] = if (in.isNextToken('{'))
[info] if (in.isNextToken('}'))
[info] default
[info] else
[info] {
[info] in.rollbackToken();
[info] var x = Map.empty[String, com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property];
[info] do
[info] x = x.updated(in.readKeyAsString(), d2(in, null))
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}'))
[info] x
[info] else
[info] in.objectEndOrCommaError()
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def d0(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root = if (in.isNextToken('{'))
[info] {
[info] var _$schema: String = null;
[info] var _type: String = null;
[info] var _properties: scala.collection.immutable.Map[String,com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property] = Map.empty[String, com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property];
[info] var _required: List[String] = Root.`<init>$default$4`;
[info] var _format: Option[String] = Root.`<init>$default$5`;
[info] var p0 = 31;
[info] if (in.isNextToken('}').`unary_!`)
[info] {
[info] in.rollbackToken();
[info] do
[info] {
[info] val l = in.readKeyAsCharBuf();
[info] (in.charBufToHashCode(l): @switch) match {
[info] case 977373893 => if (in.isCharBufEqualsTo(l, "$schema"))
[info] {
[info] if (p0.&(1).!=(0))
[info] p0.^=(1)
[info] else
[info] in.duplicatedKeyError(l);
[info] _$schema = in.readString(_$schema)
[info] }
[info] else
[info] in.skip()
[info] case 3575610 => if (in.isCharBufEqualsTo(l, "type"))
[info] {
[info] if (p0.&(2).!=(0))
[info] p0.^=(2)
[info] else
[info] in.duplicatedKeyError(l);
[info] _type = in.readString(_type)
[info] }
[info] else
[info] in.skip()
[info] case -926053069 => if (in.isCharBufEqualsTo(l, "properties"))
[info] {
[info] if (p0.&(4).!=(0))
[info] p0.^=(4)
[info] else
[info] in.duplicatedKeyError(l);
[info] _properties = d1(in, _properties)
[info] }
[info] else
[info] in.skip()
[info] case -393139297 => if (in.isCharBufEqualsTo(l, "required"))
[info] {
[info] if (p0.&(8).!=(0))
[info] p0.^=(8)
[info] else
[info] in.duplicatedKeyError(l);
[info] _required = d6(in, _required)
[info] }
[info] else
[info] in.skip()
[info] case -1268779017 => if (in.isCharBufEqualsTo(l, "format"))
[info] {
[info] if (p0.&(16).!=(0))
[info] p0.^=(16)
[info] else
[info] in.duplicatedKeyError(l);
[info] _format = d4(in, _format)
[info] }
[info] else
[info] in.skip()
[info] case _ => in.skip()
[info] }
[info] }
[info] while (in.isNextToken(',')) ;
[info] if (in.isCurrentToken('}').`unary_!`)
[info] in.objectEndOrCommaError()
[info] else
[info] ()
[info] }
[info] else
[info] ();
[info] if (p0.&(3).!=(0))
[info] in.requiredFieldError(r0(Integer.numberOfTrailingZeros(p0)))
[info] else
[info] ();
[info] new com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root($schema = _$schema, `type` = _type, properties = _properties, required = _required, format = _format)
[info] }
[info] else
[info] in.readNullOrTokenError(default, '{');
[info] private[this] def e3(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.BasicProperty, out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] {
[info] out.writeNonEscapedAsciiKey("typ");
[info] out.writeNonEscapedAsciiVal("BasicProperty")
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("type");
[info] out.writeVal(x.`type`)
[info] };
[info] {
[info] val v = x.format;
[info] if (v.isEmpty.`unary_!`.&&(v.!=(BasicProperty.`<init>$default$2`)))
[info] {
[info] out.writeNonEscapedAsciiKey("format");
[info] out.writeVal(v.get)
[info] }
[info] else
[info] ()
[info] };
[info] out.writeObjectEnd()
[info] };
[info] private[this] def e5(x: List[String], out: JsonWriter): Unit = {
[info] out.writeArrayStart();
[info] var l = x;
[info] while (l.isEmpty.`unary_!`)
[info] {
[info] out.writeComma();
[info] out.writeVal(l.head);
[info] l = l.tail
[info] }
[info] ;
[info] out.writeArrayEnd()
[info] };
[info] private[this] def e4(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.EnumProperty, out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] {
[info] out.writeNonEscapedAsciiKey("typ");
[info] out.writeNonEscapedAsciiVal("EnumProperty")
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("type");
[info] out.writeVal(x.`type`)
[info] };
[info] {
[info] val v = x.enum;
[info] if (v.isEmpty.`unary_!`)
[info] {
[info] out.writeNonEscapedAsciiKey("enum");
[info] e5(v, out)
[info] }
[info] else
[info] ()
[info] };
[info] out.writeObjectEnd()
[info] };
[info] private[this] def e6(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ArrayProperty, out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] {
[info] out.writeNonEscapedAsciiKey("typ");
[info] out.writeNonEscapedAsciiVal("ArrayProperty")
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("type");
[info] out.writeVal(x.`type`)
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("items");
[info] e2(x.items, out)
[info] };
[info] out.writeObjectEnd()
[info] };
[info] private[this] def e7(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ComplexProperty, out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] {
[info] out.writeNonEscapedAsciiKey("typ");
[info] out.writeNonEscapedAsciiVal("ComplexProperty")
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("type");
[info] out.writeVal(x.`type`)
[info] };
[info] {
[info] val v = x.properties;
[info] if (v.isEmpty.`unary_!`)
[info] {
[info] out.writeNonEscapedAsciiKey("properties");
[info] e1(v, out)
[info] }
[info] else
[info] ()
[info] };
[info] {
[info] val v = x.format;
[info] if (v.isEmpty.`unary_!`.&&(v.!=(ComplexProperty.`<init>$default$3`)))
[info] {
[info] out.writeNonEscapedAsciiKey("format");
[info] out.writeVal(v.get)
[info] }
[info] else
[info] ()
[info] };
[info] {
[info] val v = x.required;
[info] if (v.isEmpty.`unary_!`.&&(v.!=(ComplexProperty.`<init>$default$4`)))
[info] {
[info] out.writeNonEscapedAsciiKey("required");
[info] e5(v, out)
[info] }
[info] else
[info] ()
[info] };
[info] out.writeObjectEnd()
[info] };
[info] private[this] def e2(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property, out: JsonWriter): Unit = x match {
[info] case (x @ ((_): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.BasicProperty)) => e3(x, out)
[info] case (x @ ((_): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root)) => JsonSchema.this.RootCodec.encodeValue(x, out)
[info] case (x @ ((_): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.EnumProperty)) => e4(x, out)
[info] case (x @ ((_): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ArrayProperty)) => e6(x, out)
[info] case (x @ ((_): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.ComplexProperty)) => e7(x, out)
[info] };
[info] private[this] def e1(x: scala.collection.immutable.Map[String,com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Property], out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] x.foreach(((kv) => {
[info] out.writeKey(kv._1);
[info] e2(kv._2, out)
[info] }));
[info] out.writeObjectEnd()
[info] };
[info] private[this] def e0(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root, out: JsonWriter): Unit = {
[info] out.writeObjectStart();
[info] {
[info] out.writeNonEscapedAsciiKey("$schema");
[info] out.writeVal(x.$schema)
[info] };
[info] {
[info] out.writeNonEscapedAsciiKey("type");
[info] out.writeVal(x.`type`)
[info] };
[info] {
[info] val v = x.properties;
[info] if (v.isEmpty.`unary_!`)
[info] {
[info] out.writeNonEscapedAsciiKey("properties");
[info] e1(v, out)
[info] }
[info] else
[info] ()
[info] };
[info] {
[info] val v = x.required;
[info] if (v.isEmpty.`unary_!`.&&(v.!=(Root.`<init>$default$4`)))
[info] {
[info] out.writeNonEscapedAsciiKey("required");
[info] e5(v, out)
[info] }
[info] else
[info] ()
[info] };
[info] {
[info] val v = x.format;
[info] if (v.isEmpty.`unary_!`.&&(v.!=(Root.`<init>$default$5`)))
[info] {
[info] out.writeNonEscapedAsciiKey("format");
[info] out.writeVal(v.get)
[info] }
[info] else
[info] ()
[info] };
[info] out.writeObjectEnd()
[info] }
[info] };
[info] new $anon()
[info] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment