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

org.http4k.connect.mattermost.action.KotshiTriggerWebhookPayloadJsonAdapter.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.action

import com.squareup.moshi.JsonAdapter
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.reflect.Constructor
import kotlin.Any
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.apply
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.setOf
import kotlin.jvm.Throws
import kotlin.jvm.Volatile
import kotlin.jvm.`internal`.DefaultConstructorMarker
import org.http4k.connect.mattermost.model.Attachment
import org.http4k.connect.mattermost.model.EmojiName
import org.http4k.core.Uri
import se.ansman.kotshi.InternalKotshiApi
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 KotshiTriggerWebhookPayloadJsonAdapter(
  moshi: Moshi,
) : NamedJsonAdapter("KotshiJsonAdapter(TriggerWebhookPayload)") {
  private val attachmentsAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(List::class.javaObjectType, Attachment::class.javaObjectType),
      setOf(),
      "attachments"
  )

  private val iconUrlAdapter: JsonAdapter = moshi.adapter(
      Uri::class.javaObjectType,
      setOf(),
      "iconUrl"
  )

  private val iconEmojiAdapter: JsonAdapter = moshi.adapter(
      EmojiName::class.javaObjectType,
      setOf(),
      "iconEmoji"
  )

  private val propsAdapter: JsonAdapter?> = moshi.adapter(
      newParameterizedType(Map::class.javaObjectType, String::class.javaObjectType,
          Any::class.javaObjectType),
      setOf(),
      "props"
  )

  private val options: JsonReader.Options = JsonReader.Options.of(
      "text",
      "attachments",
      "channel",
      "username",
      "icon_url",
      "icon_emoji",
      "type",
      "props"
  )

  @Volatile
  private var defaultConstructor: Constructor? = null

  @Throws(IOException::class)
  override fun toJson(writer: JsonWriter, `value`: TriggerWebhookPayload?) {
    if (`value` == null) {
      writer.nullValue()
      return
    }
    writer
      .beginObject()
      .name("text").value(`value`.text)
      .name("attachments").apply {
        attachmentsAdapter.toJson(this, `value`.attachments)
      }
      .name("channel").value(`value`.channel)
      .name("username").value(`value`.username)
      .name("icon_url").apply {
        iconUrlAdapter.toJson(this, `value`.iconUrl)
      }
      .name("icon_emoji").apply {
        iconEmojiAdapter.toJson(this, `value`.iconEmoji)
      }
      .name("type").value(`value`.type)
      .name("props").apply {
        propsAdapter.toJson(this, `value`.props)
      }
      .endObject()
  }

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

    var mask = -1
    var text: String? = null
    var attachments: List? = null
    var channel: String? = null
    var username: String? = null
    var iconUrl: Uri? = null
    var iconEmoji: EmojiName? = null
    var type: String? = null
    var props: Map? = null

    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            text = reader.nextString()
          }
          // $mask = $mask and (1 shl 0).inv()
          mask = mask and 0xfffffffe.toInt()
        }
        1 -> {
          attachments = attachmentsAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 1).inv()
          mask = mask and 0xfffffffd.toInt()
        }
        2 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            channel = reader.nextString()
          }
          // $mask = $mask and (1 shl 2).inv()
          mask = mask and 0xfffffffb.toInt()
        }
        3 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            username = reader.nextString()
          }
          // $mask = $mask and (1 shl 3).inv()
          mask = mask and 0xfffffff7.toInt()
        }
        4 -> {
          iconUrl = iconUrlAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 4).inv()
          mask = mask and 0xffffffef.toInt()
        }
        5 -> {
          iconEmoji = iconEmojiAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 5).inv()
          mask = mask and 0xffffffdf.toInt()
        }
        6 -> {
          if (reader.peek() == JsonReader.Token.NULL) {
            reader.skipValue()
          } else {
            type = reader.nextString()
          }
          // $mask = $mask and (1 shl 6).inv()
          mask = mask and 0xffffffbf.toInt()
        }
        7 -> {
          props = propsAdapter.fromJson(reader)
          // $mask = $mask and (1 shl 7).inv()
          mask = mask and 0xffffff7f.toInt()
        }
        -1 -> {
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()

    return if (mask == 0xffffff00.toInt()) {
      TriggerWebhookPayload(
          text = text,
          attachments = attachments,
          channel = channel,
          username = username,
          iconUrl = iconUrl,
          iconEmoji = iconEmoji,
          type = type,
          props = props
      )
    } else {
      // Reflectively invoke the synthetic defaults constructor
      @Suppress("UNCHECKED_CAST")
      val localConstructor: Constructor = this.defaultConstructor ?:
          TriggerWebhookPayload::class.java.getDeclaredConstructor(
            String::class.java,
            List::class.java,
            String::class.java,
            String::class.java,
            Uri::class.java,
            EmojiName::class.java,
            String::class.java,
            Map::class.java,
            Int::class.javaPrimitiveType,
            DefaultConstructorMarker::class.java
          ).also { this.defaultConstructor = it }
      localConstructor.newInstance(
          text,
          attachments,
          channel,
          username,
          iconUrl,
          iconEmoji,
          type,
          props,
          mask,
          /* DefaultConstructorMarker */ null
      )
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy