From 2ffa880c11279f0838614207963c323bfc5b61e0 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:27:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Block=E3=81=AEJSON=E3=83=87=E3=82=B7?= =?UTF-8?q?=E3=83=AA=E3=82=A2=E3=83=A9=E3=82=A4=E3=82=BA=E7=94=A8POJO?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/activitypub/domain/model/Block.kt | 45 +++++++++++++++++++ .../model/objects/ObjectDeserializer.kt | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Block.kt diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Block.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Block.kt new file mode 100644 index 00000000..b1bde6d5 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Block.kt @@ -0,0 +1,45 @@ +package dev.usbharu.hideout.activitypub.domain.model + +import com.fasterxml.jackson.annotation.JsonProperty +import dev.usbharu.hideout.activitypub.domain.model.objects.Object + +open class Block( + override val actor: String, + override val id: String, + @JsonProperty("object") val apObject: String +) : + Object(listOf("Block")), HasId, HasActor { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as Block + + if (actor != other.actor) return false + if (id != other.id) return false + if (apObject != other.apObject) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + actor.hashCode() + result = 31 * result + id.hashCode() + result = 31 * result + apObject.hashCode() + return result + } + + override fun toString(): String { + return "Block(" + + "actor='$actor', " + + "id='$id', " + + "apObject='$apObject'" + + ")" + + " ${super.toString()}" + } + + +} diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt index f28070e6..677d3c7d 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt @@ -44,7 +44,7 @@ class ObjectDeserializer : JsonDeserializer() { ExtendedActivityVocabulary.Add -> TODO() ExtendedActivityVocabulary.Announce -> TODO() ExtendedActivityVocabulary.Arrive -> TODO() - ExtendedActivityVocabulary.Block -> TODO() + ExtendedActivityVocabulary.Block -> p.codec.treeToValue(treeNode, Block::class.java) ExtendedActivityVocabulary.Create -> p.codec.treeToValue(treeNode, Create::class.java) ExtendedActivityVocabulary.Delete -> p.codec.treeToValue(treeNode, Delete::class.java) ExtendedActivityVocabulary.Dislike -> TODO()