reafactor: その他の部分もNull-safeに

This commit is contained in:
usbharu 2023-11-28 12:10:40 +09:00
parent 2e1cee4e1a
commit 4542fdf68b
12 changed files with 64 additions and 116 deletions

View File

@ -8,9 +8,7 @@ import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
open class Accept @JsonCreator constructor( open class Accept @JsonCreator constructor(
type: List<String> = emptyList(), type: List<String> = emptyList(),
override val name: String, override val name: String,
@JsonDeserialize(using = ObjectDeserializer::class) @JsonDeserialize(using = ObjectDeserializer::class) @Suppress("VariableNaming") var `object`: Object?,
@Suppress("VariableNaming")
var `object`: Object?,
override val actor: String override val actor: String
) : Object( ) : Object(
type = add(type, "Accept") type = add(type, "Accept")

View File

@ -9,11 +9,11 @@ open class Create(
override val name: String, override val name: String,
@JsonDeserialize(using = ObjectDeserializer::class) @JsonDeserialize(using = ObjectDeserializer::class)
@Suppress("VariableNaming") @Suppress("VariableNaming")
var `object`: Object?, val `object`: Object,
override val actor: String, override val actor: String,
override val id: String, override val id: String,
var to: List<String> = emptyList(), val to: List<String> = emptyList(),
var cc: List<String> = emptyList() val cc: List<String> = emptyList()
) : Object( ) : Object(
type = add(type, "Create") type = add(type, "Create")
), ),

View File

@ -7,8 +7,8 @@ import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
open class Delete : Object, HasId, HasActor { open class Delete : Object, HasId, HasActor {
@JsonDeserialize(using = ObjectDeserializer::class) @JsonDeserialize(using = ObjectDeserializer::class)
@Suppress("VariableNaming") @Suppress("VariableNaming")
var `object`: Object? = null val `object`: Object
var published: String? = null val published: String
override val actor: String override val actor: String
override val id: String override val id: String
@ -17,7 +17,7 @@ open class Delete : Object, HasId, HasActor {
actor: String, actor: String,
id: String, id: String,
`object`: Object, `object`: Object,
published: String? published: String
) : super(add(type, "Delete")) { ) : super(add(type, "Delete")) {
this.`object` = `object` this.`object` = `object`
this.published = published this.published = published

View File

@ -5,16 +5,13 @@ import dev.usbharu.hideout.activitypub.domain.model.objects.Object
open class Document( open class Document(
type: List<String> = emptyList(), type: List<String> = emptyList(),
override val name: String = "", override val name: String = "",
mediaType: String, val mediaType: String,
url: String val url: String
) : Object( ) : Object(
type = add(type, "Document") type = add(type, "Document")
), ),
HasName { HasName {
var mediaType: String? = mediaType
var url: String? = url
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (javaClass != other?.javaClass) return false if (javaClass != other?.javaClass) return false

View File

@ -6,8 +6,8 @@ open class Emoji(
type: List<String>, type: List<String>,
override val name: String, override val name: String,
override val id: String, override val id: String,
var updated: String?, val updated: String,
var icon: Image? val icon: Image
) : Object( ) : Object(
type = add(type, "Emoji") type = add(type, "Emoji")
), ),

View File

@ -2,22 +2,14 @@ package dev.usbharu.hideout.activitypub.domain.model
import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.Object
open class Follow : Object, HasActor { open class Follow(
@Suppress("VariableNaming")
var `object`: String? = null
override val actor: String
constructor(
type: List<String> = emptyList(), type: List<String> = emptyList(),
`object`: String?, @Suppress("VariableNaming") val `object`: String,
actor: String override val actor: String
) : super( ) : Object(
type = add(type, "Follow") type = add(type, "Follow")
) { ),
this.`object` = `object` HasActor {
this.actor = actor
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true

View File

@ -2,17 +2,13 @@ package dev.usbharu.hideout.activitypub.domain.model
import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.Object
open class Image : Object { open class Image(
private var mediaType: String? = null type: List<String> = emptyList(),
private var url: String? = null val mediaType: String,
val url: String
protected constructor() : super() ) : Object(
constructor(type: List<String> = emptyList(), mediaType: String?, url: String?) : super(
add(type, "Image") add(type, "Image")
) { ) {
this.mediaType = mediaType
this.url = url
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true

View File

@ -2,23 +2,15 @@ package dev.usbharu.hideout.activitypub.domain.model
import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.Object
open class Key : Object, HasId { open class Key(
var owner: String? = null
var publicKeyPem: String? = null
override val id: String
constructor(
type: List<String>, type: List<String>,
id: String, override val id: String,
owner: String?, val owner: String,
publicKeyPem: String? val publicKeyPem: String
) : super( ) : Object(
type = add(list = type, type = "Key") type = add(list = type, type = "Key")
) { ),
this.owner = owner HasId {
this.publicKeyPem = publicKeyPem
this.id = id
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true

View File

@ -4,32 +4,18 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.Object
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
open class Like : Object, HasId, HasActor { open class Like(
@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
constructor(
type: List<String> = emptyList(), type: List<String> = emptyList(),
actor: String, override val actor: String,
id: String, override val id: String,
`object`: String?, @Suppress("VariableNaming") val `object`: String,
content: String?, val content: String,
tag: List<Object> = emptyList() @JsonDeserialize(contentUsing = ObjectDeserializer::class) val tag: List<Object> = emptyList()
) : super( ) : Object(
type = add(type, "Like") type = add(type, "Like")
) { ),
this.`object` = `object` HasId,
this.content = content HasActor {
this.tag = tag
this.actor = actor
this.id = id
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true

View File

@ -7,14 +7,14 @@ open class Note
constructor( constructor(
type: List<String> = emptyList(), type: List<String> = emptyList(),
override val id: String, override val id: String,
var attributedTo: String, val attributedTo: String,
var content: String, val content: String,
var published: String, val published: String,
var to: List<String> = emptyList(), val to: List<String> = emptyList(),
var cc: List<String> = emptyList(), val cc: List<String> = emptyList(),
var sensitive: Boolean = false, val sensitive: Boolean = false,
var inReplyTo: String? = null, val inReplyTo: String? = null,
var attachment: List<Document> = emptyList() val attachment: List<Document> = emptyList()
) : Object( ) : Object(
type = add(type, "Note") type = add(type, "Note")
), ),

View File

@ -10,9 +10,9 @@ constructor(
override val id: String, override val id: String,
var preferredUsername: String?, var preferredUsername: String?,
var summary: String?, var summary: String?,
var inbox: String?, var inbox: String,
var outbox: String?, var outbox: String,
var url: String?, var url: String,
private var icon: Image?, private var icon: Image?,
var publicKey: Key?, var publicKey: Key?,
var endpoints: Map<String, String> = emptyMap(), var endpoints: Map<String, String> = emptyMap(),

View File

@ -4,27 +4,14 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.Object
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer
open class Undo : Object, HasId, HasActor { open class Undo(
@JsonDeserialize(using = ObjectDeserializer::class)
@Suppress("VariableNaming")
var `object`: Object? = null
var published: String? = null
override val actor: String
override val id: String
constructor(
type: List<String> = emptyList(), type: List<String> = emptyList(),
actor: String, override val actor: String,
id: String, override val id: String,
`object`: Object, @JsonDeserialize(using = ObjectDeserializer::class)
published: String @Suppress("VariableNaming") val `object`: Object,
) : super(add(type, "Undo")) { val published: String
this.`object` = `object` ) : Object(add(type, "Undo")), HasId, HasActor {
this.published = published
this.id = id
this.actor = actor
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true