All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.connect.mattermost.model.KotshiPostActionJsonAdapter.kt Maven / Gradle / Ivy

There is a newer version: 5.25.0.0
Show newest version
// Code generated by Kotshi. Do not edit.
package org.http4k.connect.mattermost.model

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types.newParameterizedType
import java.io.IOException
import java.lang.StringBuilder
import java.lang.reflect.Constructor
import kotlin.Boolean
import kotlin.Int
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import se.ansman.kotshi.InternalKotshiApi
import se.ansman.kotshi.KotshiUtils.appendNullableError
import se.ansman.kotshi.NamedJsonAdapter

@InternalKotshiApi
@Suppress(
  "DEPRECATION",
  "unused",
  "ClassName",
  "REDUNDANT_PROJECTION",
  "RedundantExplicitType",
  "LocalVariableName",
  "RedundantVisibilityModifier",
  "PLATFORM_CLASS_MAPPED_TO_KOTLIN",
  "IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION",
  "EXPERIMENTAL_API_USAGE",
  "OPT_IN_USAGE",
)
internal class KotshiPostActionJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(PostAction)") {
  private val idAdapter: JsonAdapter = moshi.adapter(
      PostActionId::class.javaObjectType,
      setOf(),
      "id"
  )

  private val typeAdapter: JsonAdapter = moshi.adapter(
      PostActionType::class.javaObjectType,
      setOf(),
      "type"
  )

  private val nameAdapter: JsonAdapter = moshi.adapter(
      PostActionName::class.javaObjectType,
      setOf(),
      "name"
  )

  private val styleAdapter: JsonAdapter = moshi.adapter(
      PostActionStyle::class.javaObjectType,
      setOf(),
      "style"
  )

  private val dataSourceAdapter: JsonAdapter = moshi.adapter(
      PostActionDataSource::class.javaObjectType,
      setOf(),
      "dataSource"
  )

  private val optionsAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(List::class.javaObjectType, PostActionOption::class.javaObjectType),
      setOf(),
      "options"
  )

  private val defaultOptionAdapter: JsonAdapter = moshi.adapter(
      PostActionOptionValue::class.javaObjectType,
      setOf(),
      "defaultOption"
  )

  private val integrationAdapter: JsonAdapter = moshi.adapter(
      PostActionIntegration::class.javaObjectType,
      setOf(),
      "integration"
  )

  private val cookieAdapter: JsonAdapter = moshi.adapter(
      PostActionCookie::class.javaObjectType,
      setOf(),
      "cookie"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "id",
      "type",
      "name",
      "disabled",
      "style",
      "data_source",
      "options",
      "default_option",
      "integration",
      "cookie"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: PostAction?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("id").apply {
        idAdapter.toJson(this, `value`.id)
      }
      .name("type").apply {
        typeAdapter.toJson(this, `value`.type)
      }
      .name("name").apply {
        nameAdapter.toJson(this, `value`.name)
      }
      .name("disabled").value(`value`.disabled)
      .name("style").apply {
        styleAdapter.toJson(this, `value`.style)
      }
      .name("data_source").apply {
        dataSourceAdapter.toJson(this, `value`.dataSource)
      }
      .name("options").apply {
        optionsAdapter.toJson(this, `value`.options)
      }
      .name("default_option").apply {
        defaultOptionAdapter.toJson(this, `value`.defaultOption)
      }
      .name("integration").apply {
        integrationAdapter.toJson(this, `value`.integration)
      }
      .name("cookie").apply {
        cookieAdapter.toJson(this, `value`.cookie)
      }
      .endObject()
  }

  @Throws(IOException::class)
  override fun fromJson(reader: JsonReader): PostAction? {
    if (reader.peek() == JsonReader.Token.NULL) return reader.nextNull()

    var mask = -1
    var id: PostActionId? = null
    var type: PostActionType? = null
    var name: PostActionName? = null
    var disabled: Boolean? = null
    var style: PostActionStyle? = null
    var dataSource: PostActionDataSource? = null
    var options_: List? = null
    var defaultOption: PostActionOptionValue? = null
    var integration: PostActionIntegration? = null
    var cookie: PostActionCookie? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          id = idAdapter.fromJson(reader)
        }
        1 -> {
          type = typeAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 1).inv()
          mask = mask and 0xfffffffd.toInt()
        }
        2 -> {
          name = nameAdapter.fromJson(reader)
        }
        3 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            disabled = reader.nextBoolean()
          }
          // $mask = $mask and (1 shl 3).inv()
          mask = mask and 0xfffffff7.toInt()
        }
        4 -> {
          style = styleAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 4).inv()
          mask = mask and 0xffffffef.toInt()
        }
        5 -> {
          dataSource = dataSourceAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 5).inv()
          mask = mask and 0xffffffdf.toInt()
        }
        6 -> {
          options_ = optionsAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 6).inv()
          mask = mask and 0xffffffbf.toInt()
        }
        7 -> {
          defaultOption = defaultOptionAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 7).inv()
          mask = mask and 0xffffff7f.toInt()
        }
        8 -> {
          integration = integrationAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 8).inv()
          mask = mask and 0xfffffeff.toInt()
        }
        9 -> {
          cookie = cookieAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 9).inv()
          mask = mask and 0xfffffdff.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    var errorBuilder: StringBuilder? = null
    if (id == null) {
      errorBuilder = errorBuilder.appendNullableError("id")
    }
    if (name == null) {
      errorBuilder = errorBuilder.appendNullableError("name")
    }
    if (errorBuilder != null) {
      errorBuilder.append(" (at path ").append(reader.path).append(')')
      throw JsonDataException(errorBuilder.toString())
    }

    return if (mask == 0xfffffc05.toInt()) {
      PostAction(
          id = id!!,
          type = type,
          name = name!!,
          disabled = disabled,
          style = style,
          dataSource = dataSource,
          options = options_,
          defaultOption = defaultOption,
          integration = integration,
          cookie = cookie
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor = this.defaultConstructor ?:
          PostAction::class.java.getDeclaredConstructor(
            PostActionId::class.java,
            PostActionType::class.java,
            PostActionName::class.java,
            Boolean::class.javaObjectType,
            PostActionStyle::class.java,
            PostActionDataSource::class.java,
            List::class.java,
            PostActionOptionValue::class.java,
            PostActionIntegration::class.java,
            PostActionCookie::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          id,
          type,
          name,
          disabled,
          style,
          dataSource,
          options_,
          defaultOption,
          integration,
          cookie,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy