mirror of https://github.com/usbharu/Hideout.git
refactor: Objectを継承するJSONマッピング用のPOJOをNull-safeに
This commit is contained in:
parent
6c2d5dae94
commit
7a34b11147
|
@ -1,41 +1,46 @@
|
|||
package dev.usbharu.hideout.activitypub.domain.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
|
||||
|
||||
open class Accept : Object {
|
||||
open class Accept @JsonCreator constructor(
|
||||
type: List<String> = emptyList(),
|
||||
override val name: String,
|
||||
@JsonDeserialize(using = ObjectDeserializer::class)
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: Object? = null
|
||||
|
||||
protected constructor()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
`object`: Object?,
|
||||
actor: String?
|
||||
) : super(
|
||||
type = add(type, "Accept"),
|
||||
name = name,
|
||||
actor = actor
|
||||
) {
|
||||
this.`object` = `object`
|
||||
}
|
||||
|
||||
override fun toString(): String = "Accept(`object`=$`object`) ${super.toString()}"
|
||||
var `object`: Object?,
|
||||
override val actor: String
|
||||
) : Object(
|
||||
type = add(type, "Accept")
|
||||
),
|
||||
HasActor,
|
||||
HasName {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Accept) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
return `object` == other.`object`
|
||||
other as Accept
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
if (actor != other.actor) return false
|
||||
if (name != other.name) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + actor.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Accept(" + "`object`=$`object`, " + "actor='$actor', " + "name='$name'" + ")" + " ${super.toString()}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,46 +4,51 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
|||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
|
||||
|
||||
open class Create : Object {
|
||||
open class Create(
|
||||
type: List<String> = emptyList(),
|
||||
override val name: String,
|
||||
@JsonDeserialize(using = ObjectDeserializer::class)
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: Object? = null
|
||||
var to: List<String> = emptyList()
|
||||
var `object`: Object?,
|
||||
override val actor: String,
|
||||
override val id: String,
|
||||
var to: List<String> = emptyList(),
|
||||
var cc: List<String> = emptyList()
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String? = null,
|
||||
`object`: Object?,
|
||||
actor: String? = null,
|
||||
id: String? = null,
|
||||
to: List<String> = emptyList(),
|
||||
cc: List<String> = emptyList()
|
||||
) : super(
|
||||
type = add(type, "Create"),
|
||||
name = name,
|
||||
actor = actor,
|
||||
id = id
|
||||
) {
|
||||
this.`object` = `object`
|
||||
this.to = to
|
||||
this.cc = cc
|
||||
}
|
||||
) : Object(
|
||||
type = add(type, "Create")
|
||||
),
|
||||
HasId,
|
||||
HasName,
|
||||
HasActor {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Create) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
return `object` == other.`object`
|
||||
other as Create
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
if (to != other.to) return false
|
||||
if (cc != other.cc) return false
|
||||
if (name != other.name) return false
|
||||
if (actor != other.actor) return false
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + to.hashCode()
|
||||
result = 31 * result + cc.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + actor.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Create(`object`=$`object`) ${super.toString()}"
|
||||
override fun toString(): String =
|
||||
"Create(`object`=$`object`, to=$to, cc=$cc, name='$name', actor='$actor', id='$id') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -4,33 +4,42 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
|||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
|
||||
|
||||
open class Delete : Object {
|
||||
open class Delete : Object, HasId, HasActor, HasName {
|
||||
@JsonDeserialize(using = ObjectDeserializer::class)
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: Object? = null
|
||||
var published: String? = null
|
||||
override val actor: String
|
||||
override val id: String
|
||||
override val name: String
|
||||
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String? = "Delete",
|
||||
name: String = "Delete",
|
||||
actor: String,
|
||||
id: String,
|
||||
`object`: Object,
|
||||
published: String?
|
||||
) : super(add(type, "Delete"), name, actor, id) {
|
||||
) : super(add(type, "Delete")) {
|
||||
this.`object` = `object`
|
||||
this.published = published
|
||||
this.name = name
|
||||
this.actor = actor
|
||||
this.id = id
|
||||
}
|
||||
|
||||
protected constructor() : super()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Delete) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Delete
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
if (published != other.published) return false
|
||||
if (actor != other.actor) return false
|
||||
if (id != other.id) return false
|
||||
if (name != other.name) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -39,8 +48,12 @@ open class Delete : Object {
|
|||
var result = super.hashCode()
|
||||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + (published?.hashCode() ?: 0)
|
||||
result = 31 * result + actor.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Delete(`object`=$`object`, published=$published) ${super.toString()}"
|
||||
override fun toString(): String =
|
||||
"Delete(`object`=$`object`, published=$published, actor='$actor', id='$id', name='$name') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -2,34 +2,35 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Document : Object {
|
||||
open class Document : Object, HasName {
|
||||
|
||||
var mediaType: String? = null
|
||||
var url: String? = null
|
||||
override val name: String
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String? = null,
|
||||
name: String,
|
||||
mediaType: String,
|
||||
url: String
|
||||
) : super(
|
||||
type = add(type, "Document"),
|
||||
name = name,
|
||||
actor = null,
|
||||
id = null
|
||||
type = add(type, "Document")
|
||||
) {
|
||||
this.mediaType = mediaType
|
||||
this.url = url
|
||||
this.name = name
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Document) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Document
|
||||
|
||||
if (mediaType != other.mediaType) return false
|
||||
if (url != other.url) return false
|
||||
if (name != other.name) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -38,8 +39,9 @@ open class Document : Object {
|
|||
var result = super.hashCode()
|
||||
result = 31 * result + (mediaType?.hashCode() ?: 0)
|
||||
result = 31 * result + (url?.hashCode() ?: 0)
|
||||
result = 31 * result + name.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Document(mediaType=$mediaType, url=$url) ${super.toString()}"
|
||||
override fun toString(): String = "Document(mediaType=$mediaType, url=$url, name='$name') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -15,10 +15,7 @@ open class Emoji : Object {
|
|||
updated: String?,
|
||||
icon: Image?
|
||||
) : super(
|
||||
type = add(type, "Emoji"),
|
||||
name = name,
|
||||
actor = actor,
|
||||
id = id
|
||||
type = add(type, "Emoji")
|
||||
) {
|
||||
this.updated = updated
|
||||
this.icon = icon
|
||||
|
|
|
@ -2,37 +2,42 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Follow : Object {
|
||||
open class Follow : Object, HasActor {
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
override val actor: String
|
||||
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String?,
|
||||
`object`: String?,
|
||||
actor: String?
|
||||
actor: String
|
||||
) : super(
|
||||
type = add(type, "Follow"),
|
||||
name = name,
|
||||
actor = actor
|
||||
type = add(type, "Follow")
|
||||
) {
|
||||
this.`object` = `object`
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Follow) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
return `object` == other.`object`
|
||||
other as Follow
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
if (actor != other.actor) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + actor.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Follow(`object`=$`object`) ${super.toString()}"
|
||||
override fun toString(): String = "Follow(`object`=$`object`, actor='$actor') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package dev.usbharu.hideout.activitypub.domain.model
|
||||
|
||||
interface HasActor {
|
||||
val actor: String
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package dev.usbharu.hideout.activitypub.domain.model
|
||||
|
||||
interface HasId {
|
||||
val id: String
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package dev.usbharu.hideout.activitypub.domain.model
|
||||
|
||||
interface HasName {
|
||||
val name: String
|
||||
}
|
|
@ -7,9 +7,8 @@ open class Image : Object {
|
|||
private var url: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String> = emptyList(), name: String, mediaType: String?, url: String?) : super(
|
||||
add(type, "Image"),
|
||||
name
|
||||
constructor(type: List<String> = emptyList(), mediaType: String?, url: String?) : super(
|
||||
add(type, "Image")
|
||||
) {
|
||||
this.mediaType = mediaType
|
||||
this.url = url
|
||||
|
@ -17,11 +16,15 @@ open class Image : Object {
|
|||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Image) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Image
|
||||
|
||||
if (mediaType != other.mediaType) return false
|
||||
return url == other.url
|
||||
if (url != other.url) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
|
@ -30,4 +33,6 @@ open class Image : Object {
|
|||
result = 31 * result + (url?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Image(mediaType=$mediaType, url=$url) ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -2,41 +2,45 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Key : Object {
|
||||
open class Key : Object, HasId {
|
||||
var owner: String? = null
|
||||
var publicKeyPem: String? = null
|
||||
override val id: String
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String>,
|
||||
name: String,
|
||||
id: String,
|
||||
owner: String?,
|
||||
publicKeyPem: String?
|
||||
) : super(
|
||||
type = add(list = type, type = "Key"),
|
||||
name = name,
|
||||
id = id
|
||||
type = add(list = type, type = "Key")
|
||||
) {
|
||||
this.owner = owner
|
||||
this.publicKeyPem = publicKeyPem
|
||||
this.id = id
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Key) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Key
|
||||
|
||||
if (owner != other.owner) return false
|
||||
return publicKeyPem == other.publicKeyPem
|
||||
if (publicKeyPem != other.publicKeyPem) return false
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (owner?.hashCode() ?: 0)
|
||||
result = 31 * result + (publicKeyPem?.hashCode() ?: 0)
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Key(owner=$owner, publicKeyPem=$publicKeyPem) ${super.toString()}"
|
||||
override fun toString(): String = "Key(owner=$owner, publicKeyPem=$publicKeyPem, id='$id') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -4,42 +4,47 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
|||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
|
||||
|
||||
open class Like : Object {
|
||||
open class Like : Object, HasId, HasActor {
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: String? = null
|
||||
var content: String? = null
|
||||
|
||||
@JsonDeserialize(contentUsing = ObjectDeserializer::class)
|
||||
var tag: List<Object> = emptyList()
|
||||
override val actor: String
|
||||
override val id: String
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String?,
|
||||
actor: String?,
|
||||
id: String?,
|
||||
actor: String,
|
||||
id: String,
|
||||
`object`: String?,
|
||||
content: String?,
|
||||
tag: List<Object> = emptyList()
|
||||
) : super(
|
||||
type = add(type, "Like"),
|
||||
name = name,
|
||||
actor = actor,
|
||||
id = id
|
||||
type = add(type, "Like")
|
||||
) {
|
||||
this.`object` = `object`
|
||||
this.content = content
|
||||
this.tag = tag
|
||||
this.actor = actor
|
||||
this.id = id
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Like) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Like
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
if (content != other.content) return false
|
||||
return tag == other.tag
|
||||
if (tag != other.tag) return false
|
||||
if (actor != other.actor) return false
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
|
@ -47,8 +52,12 @@ open class Like : Object {
|
|||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + (content?.hashCode() ?: 0)
|
||||
result = 31 * result + tag.hashCode()
|
||||
result = 31 * result + actor.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Like(`object`=$`object`, content=$content, tag=$tag) ${super.toString()}"
|
||||
override fun toString(): String {
|
||||
return "Like(`object`=$`object`, content=$content, tag=$tag, actor='$actor', id='$id') ${super.toString()}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,79 +2,58 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Note : Object {
|
||||
lateinit var attributedTo: String
|
||||
var attachment: List<Document> = emptyList()
|
||||
lateinit var content: String
|
||||
lateinit var published: String
|
||||
var to: List<String> = emptyList()
|
||||
var cc: List<String> = emptyList()
|
||||
var sensitive: Boolean = false
|
||||
var inReplyTo: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
|
||||
open class Note
|
||||
@Suppress("LongParameterList")
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
id: String?,
|
||||
attributedTo: String,
|
||||
content: String,
|
||||
published: String,
|
||||
to: List<String> = emptyList(),
|
||||
cc: List<String> = emptyList(),
|
||||
sensitive: Boolean = false,
|
||||
inReplyTo: String? = null,
|
||||
attachment: List<Document> = emptyList()
|
||||
) : super(
|
||||
type = add(type, "Note"),
|
||||
name = name,
|
||||
id = id
|
||||
) {
|
||||
this.attributedTo = attributedTo
|
||||
this.content = content
|
||||
this.published = published
|
||||
this.to = to
|
||||
this.cc = cc
|
||||
this.sensitive = sensitive
|
||||
this.inReplyTo = inReplyTo
|
||||
this.attachment = attachment
|
||||
}
|
||||
override val id: String,
|
||||
var attributedTo: String,
|
||||
var content: String,
|
||||
var published: String,
|
||||
var to: List<String> = emptyList(),
|
||||
var cc: List<String> = emptyList(),
|
||||
var sensitive: Boolean = false,
|
||||
var inReplyTo: String? = null,
|
||||
var attachment: List<Document> = emptyList()
|
||||
) : Object(
|
||||
type = add(type, "Note")
|
||||
),
|
||||
HasId {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Note) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Note
|
||||
|
||||
if (id != other.id) return false
|
||||
if (attributedTo != other.attributedTo) return false
|
||||
if (attachment != other.attachment) return false
|
||||
if (content != other.content) return false
|
||||
if (published != other.published) return false
|
||||
if (to != other.to) return false
|
||||
if (cc != other.cc) return false
|
||||
if (sensitive != other.sensitive) return false
|
||||
if (inReplyTo != other.inReplyTo) return false
|
||||
if (attachment != other.attachment) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (attributedTo?.hashCode() ?: 0)
|
||||
result = 31 * result + attachment.hashCode()
|
||||
result = 31 * result + (content?.hashCode() ?: 0)
|
||||
result = 31 * result + (published?.hashCode() ?: 0)
|
||||
result = 31 * result + id.hashCode()
|
||||
result = 31 * result + attributedTo.hashCode()
|
||||
result = 31 * result + content.hashCode()
|
||||
result = 31 * result + published.hashCode()
|
||||
result = 31 * result + to.hashCode()
|
||||
result = 31 * result + cc.hashCode()
|
||||
result = 31 * result + sensitive.hashCode()
|
||||
result = 31 * result + (inReplyTo?.hashCode() ?: 0)
|
||||
result = 31 * result + attachment.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Note(attributedTo=$attributedTo, attachment=$attachment, " +
|
||||
"content=$content, published=$published, to=$to, cc=$cc, sensitive=$sensitive," +
|
||||
" inReplyTo=$inReplyTo) ${super.toString()}"
|
||||
}
|
||||
override fun toString(): String =
|
||||
"Note(id='$id', attributedTo='$attributedTo', content='$content', published='$published', to=$to, cc=$cc, sensitive=$sensitive, inReplyTo=$inReplyTo, attachment=$attachment) ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -2,47 +2,23 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Person : Object {
|
||||
var preferredUsername: String? = null
|
||||
var summary: String? = null
|
||||
var inbox: String? = null
|
||||
var outbox: String? = null
|
||||
var url: String? = null
|
||||
private var icon: Image? = null
|
||||
var publicKey: Key? = null
|
||||
var endpoints: Map<String, String> = emptyMap()
|
||||
var following: String? = null
|
||||
var followers: String? = null
|
||||
|
||||
protected constructor() : super()
|
||||
|
||||
open class Person
|
||||
@Suppress("LongParameterList")
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
id: String?,
|
||||
preferredUsername: String?,
|
||||
summary: String?,
|
||||
inbox: String?,
|
||||
outbox: String?,
|
||||
url: String?,
|
||||
icon: Image?,
|
||||
publicKey: Key?,
|
||||
endpoints: Map<String, String> = emptyMap(),
|
||||
followers: String?,
|
||||
following: String?
|
||||
) : super(add(type, "Person"), name, id = id) {
|
||||
this.preferredUsername = preferredUsername
|
||||
this.summary = summary
|
||||
this.inbox = inbox
|
||||
this.outbox = outbox
|
||||
this.url = url
|
||||
this.icon = icon
|
||||
this.publicKey = publicKey
|
||||
this.endpoints = endpoints
|
||||
this.followers = followers
|
||||
this.following = following
|
||||
}
|
||||
override val name: String,
|
||||
override val id: String,
|
||||
var preferredUsername: String?,
|
||||
var summary: String?,
|
||||
var inbox: String?,
|
||||
var outbox: String?,
|
||||
var url: String?,
|
||||
private var icon: Image?,
|
||||
var publicKey: Key?,
|
||||
var endpoints: Map<String, String> = emptyMap(),
|
||||
var followers: String?,
|
||||
var following: String?
|
||||
) : Object(add(type, "Person")), HasId, HasName {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
|
|
@ -2,11 +2,24 @@ package dev.usbharu.hideout.activitypub.domain.model
|
|||
|
||||
import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
||||
|
||||
open class Tombstone : Object {
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String = "Tombstone",
|
||||
actor: String? = null,
|
||||
id: String
|
||||
) : super(add(type, "Tombstone"), name, actor, id)
|
||||
open class Tombstone(type: List<String> = emptyList(), override val id: String) :
|
||||
Object(add(type, "Tombstone")),
|
||||
HasId {
|
||||
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 Tombstone
|
||||
|
||||
return id == other.id
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Tombstone(id='$id') ${super.toString()}"
|
||||
}
|
||||
|
|
|
@ -5,41 +5,53 @@ import dev.usbharu.hideout.activitypub.domain.model.objects.Object
|
|||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
|
||||
import java.time.Instant
|
||||
|
||||
open class Undo : Object {
|
||||
open class Undo : Object, HasId, HasActor {
|
||||
|
||||
@JsonDeserialize(using = ObjectDeserializer::class)
|
||||
@Suppress("VariableNaming")
|
||||
var `object`: Object? = null
|
||||
var published: String? = null
|
||||
override val actor: String
|
||||
override val id: String
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(
|
||||
type: List<String> = emptyList(),
|
||||
name: String,
|
||||
actor: String,
|
||||
id: String?,
|
||||
id: String,
|
||||
`object`: Object,
|
||||
published: Instant
|
||||
) : super(add(type, "Undo"), name, actor, id) {
|
||||
) : super(add(type, "Undo")) {
|
||||
this.`object` = `object`
|
||||
this.published = published.toString()
|
||||
this.id = id
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Undo) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Undo
|
||||
|
||||
if (`object` != other.`object`) return false
|
||||
return published == other.published
|
||||
if (published != other.published) return false
|
||||
if (actor != other.actor) return false
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + (`object`?.hashCode() ?: 0)
|
||||
result = 31 * result + (published?.hashCode() ?: 0)
|
||||
result = 31 * result + actor.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Undo(`object`=$`object`, published=$published) ${super.toString()}"
|
||||
override fun toString(): String {
|
||||
return "Undo(`object`=$`object`, published=$published, actor='$actor', id='$id') ${super.toString()}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,41 +12,29 @@ open class Object : JsonLd {
|
|||
set(value) {
|
||||
field = value.filter { it.isNotBlank() }
|
||||
}
|
||||
var name: String? = null
|
||||
var actor: String? = null
|
||||
var id: String? = null
|
||||
|
||||
protected constructor()
|
||||
constructor(type: List<String>, name: String? = null, actor: String? = null, id: String? = null) : super() {
|
||||
constructor(type: List<String>) : super() {
|
||||
this.type = type.filter { it.isNotBlank() }
|
||||
this.name = name
|
||||
this.actor = actor
|
||||
this.id = id
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Object) return false
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
if (type != other.type) return false
|
||||
if (name != other.name) return false
|
||||
if (actor != other.actor) return false
|
||||
if (id != other.id) return false
|
||||
other as Object
|
||||
|
||||
return true
|
||||
return type == other.type
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + type.hashCode()
|
||||
result = 31 * result + (name?.hashCode() ?: 0)
|
||||
result = 31 * result + (actor?.hashCode() ?: 0)
|
||||
result = 31 * result + (id?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String = "Object(type=$type, name=$name, actor=$actor, id=$id) ${super.toString()}"
|
||||
override fun toString(): String = "Object(type=$type) ${super.toString()}"
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package dev.usbharu.hideout.activitypub.domain.model.objects
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
|
||||
@Suppress("VariableNaming")
|
||||
open class ObjectValue : Object {
|
||||
|
||||
var `object`: String? = null
|
||||
lateinit var `object`: String
|
||||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String>, name: String?, actor: String?, id: String?, `object`: String?) : super(
|
||||
type,
|
||||
name,
|
||||
actor,
|
||||
id
|
||||
@JsonCreator
|
||||
constructor(type: List<String>) : super(
|
||||
type
|
||||
) {
|
||||
this.`object` = `object`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue