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

org.http4k.connect.mattermost.KotshiMattermostJsonAdapterFactory.kt Maven / Gradle / Ivy

There is a newer version: 5.25.0.0
Show newest version
// Code generated by Kotshi. Do not edit.
@file:Suppress(
  "EXPERIMENTAL_IS_NOT_ENABLED",
  "REDUNDANT_PROJECTION",
)

package org.http4k.connect.mattermost

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types.getRawType
import java.lang.Class
import java.lang.reflect.Type
import kotlin.Annotation
import kotlin.OptIn
import kotlin.Suppress
import kotlin.collections.Set
import org.http4k.connect.mattermost.action.KotshiTriggerWebhookPayloadJsonAdapter
import org.http4k.connect.mattermost.action.TriggerWebhookPayload
import org.http4k.connect.mattermost.model.Attachment
import org.http4k.connect.mattermost.model.AttachmentField
import org.http4k.connect.mattermost.model.KotshiAttachmentFieldJsonAdapter
import org.http4k.connect.mattermost.model.KotshiAttachmentJsonAdapter
import org.http4k.connect.mattermost.model.KotshiPostActionIntegrationJsonAdapter
import org.http4k.connect.mattermost.model.KotshiPostActionJsonAdapter
import org.http4k.connect.mattermost.model.KotshiPostActionOptionJsonAdapter
import org.http4k.connect.mattermost.model.PostAction
import org.http4k.connect.mattermost.model.PostActionIntegration
import org.http4k.connect.mattermost.model.PostActionOption
import se.ansman.kotshi.InternalKotshiApi

@OptIn(InternalKotshiApi::class)
internal object KotshiMattermostJsonAdapterFactory : JsonAdapter.Factory {
  override fun create(
    type: Type,
    annotations: Set,
    moshi: Moshi,
  ): JsonAdapter<*>? {
    val rawType: Class<*> = getRawType(type)
    if (annotations.isNotEmpty()) return null

    return when (rawType) {
      TriggerWebhookPayload::class.java ->
          KotshiTriggerWebhookPayloadJsonAdapter(
            moshi = moshi
          )
      AttachmentField::class.java ->
          KotshiAttachmentFieldJsonAdapter()
      Attachment::class.java ->
          KotshiAttachmentJsonAdapter(
            moshi = moshi
          )
      PostActionIntegration::class.java ->
          KotshiPostActionIntegrationJsonAdapter(
            moshi = moshi
          )
      PostAction::class.java ->
          KotshiPostActionJsonAdapter(
            moshi = moshi
          )
      PostActionOption::class.java ->
          KotshiPostActionOptionJsonAdapter(
            moshi = moshi
          )
      else -> null
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy