feat: Kotlinのオブジェクトに詰め込む部分を作成

This commit is contained in:
usbharu 2024-10-02 12:21:42 +09:00
parent 722ad284b0
commit 3538e9e973
Signed by: usbharu
GPG Key ID: 8CB1087135660B8D
9 changed files with 93 additions and 32 deletions

14
.idea/deployment.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="KCG">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

View File

@ -4,8 +4,8 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
@ -13,5 +13,6 @@
</option>
</GradleProjectSettings>
</option>
<option name="parallelModelFetch" value="true" />
</component>
</project>

View File

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="temurin-11" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,14 @@
package dev.usbharu.activitystreams.impl.builder
import dev.usbharu.activitystreams.impl.type.BuilderContext
import dev.usbharu.activitystreams.impl.type.JsonObjectBuilder
import dev.usbharu.activitystreams.model.JsonLd
import java.net.URI
open class JsonLdBuilder : JsonObjectBuilder<JsonLd> {
override fun build(t: JsonLd, jsonObject: Map<String, Any>, builderContext: BuilderContext) {
t.value = jsonObject["@value"]
t.id = jsonObject["@id"]?.toString()?.let { URI.create(it) }
t.type = (jsonObject["@type"] as? List<String>).orEmpty().map { URI.create(it) }
}
}

View File

@ -0,0 +1,13 @@
package dev.usbharu.activitystreams.impl.builder
import dev.usbharu.activitystreams.impl.type.BuilderContext
import dev.usbharu.activitystreams.impl.type.JsonObjectBuilder
import dev.usbharu.activitystreams.model.JsonLd
import dev.usbharu.activitystreams.model.core.Object
class ObjectBuilder : JsonObjectBuilder<Object> {
override fun build(t: Object, jsonObject: Map<String, Any>, builderContext: BuilderContext) {
// t.name =
}
}

View File

@ -1,6 +1,7 @@
package dev.usbharu.activitystreams.impl.model.`object`
import dev.usbharu.activitystreams.model.ImageOrLink
import dev.usbharu.activitystreams.model.JsonLdWrapper
import dev.usbharu.activitystreams.model.ObjectOrLink
import dev.usbharu.activitystreams.model.UriOrLink
import dev.usbharu.activitystreams.model.core.Collection
@ -12,34 +13,35 @@ import java.time.Duration
import java.time.OffsetDateTime
class NoteImpl(
override var type: List<URI>,
override var attachment: List<ObjectOrLink>,
override var attributedTo: List<ObjectOrLink>,
override var audience: List<ObjectOrLink>,
override var content: LangString?,
override var context: List<ObjectOrLink>,
override var name: LangString?,
override var endTime: OffsetDateTime?,
override var generator: List<ObjectOrLink>,
override var icon: List<ImageOrLink>,
override var image: List<ImageOrLink>,
override var inReplyTo: List<ObjectOrLink>,
override var location: ObjectOrLink?,
override var preview: ObjectOrLink?,
override var published: OffsetDateTime?,
override var replies: Collection?,
override var startTime: OffsetDateTime?,
override var summary: LangString?,
override var tag: List<ObjectOrLink>,
override var updated: OffsetDateTime?,
override var url: List<UriOrLink>,
override var to: List<ObjectOrLink>,
override var bto: List<ObjectOrLink>,
override var cc: List<ObjectOrLink>,
override var bcc: List<ObjectOrLink>,
override var mediaType: MimeMediaType?,
override var duration: Duration?,
override var id: URI?,
override var source: ObjectOrLink?
override var type: List<URI> = emptyList(),
override var attachment: List<ObjectOrLink> = emptyList(),
override var attributedTo: List<ObjectOrLink> = emptyList(),
override var audience: List<ObjectOrLink> = emptyList(),
override var content: LangString? = null,
override var context: List<ObjectOrLink> = emptyList(),
override var name: LangString? = null,
override var endTime: JsonLdWrapper<OffsetDateTime>? = null,
override var generator: List<ObjectOrLink> = emptyList(),
override var icon: List<ImageOrLink> = emptyList(),
override var image: List<ImageOrLink> = emptyList(),
override var inReplyTo: List<ObjectOrLink> = emptyList(),
override var location: ObjectOrLink? = null,
override var preview: ObjectOrLink? = null,
override var published: JsonLdWrapper<OffsetDateTime>? = null,
override var replies: Collection? = null,
override var startTime: JsonLdWrapper<OffsetDateTime>? = null,
override var summary: LangString? = null,
override var tag: List<ObjectOrLink> = emptyList(),
override var updated: JsonLdWrapper<OffsetDateTime>? = null,
override var url: List<UriOrLink> = emptyList(),
override var to: List<ObjectOrLink> = emptyList(),
override var bto: List<ObjectOrLink> = emptyList(),
override var cc: List<ObjectOrLink> = emptyList(),
override var bcc: List<ObjectOrLink> = emptyList(),
override var mediaType: MimeMediaType? = null,
override var duration: JsonLdWrapper<Duration>? = null,
override var id: URI? = null,
override var source: ObjectOrLink? = null,
override var value: Any? = null,
) : Note {
}

View File

@ -0,0 +1,7 @@
package dev.usbharu.activitystreams.impl.type
class BuilderContext {
fun <T> getBuilder():JsonObjectBuilder<T>{
TODO()
}
}

View File

@ -0,0 +1,6 @@
package dev.usbharu.activitystreams.impl.type
interface JsonObjectBuilder<T> {
fun build(t: T, jsonObject: Map<String,Any>, builderContext: BuilderContext)
}
// todo Abstract classでスーパークラスのjsonobjectbuilderを自動で呼び出す部分を作る

View File

@ -1,13 +1,17 @@
package dev.usbharu.activitystreams.impl.type
import dev.usbharu.activitystreams.impl.model.activity.CreateImpl
import dev.usbharu.activitystreams.impl.model.actor.PersonImpl
import dev.usbharu.activitystreams.impl.model.`object`.NoteImpl
import dev.usbharu.activitystreams.model.JsonLd
import java.net.URI
class TypeFactory {
val map = mutableMapOf<URI, () -> JsonLd>(
URI.create("https://www.w3.org/ns/activitystreams#Create") to { CreateImpl() }
URI.create("https://www.w3.org/ns/activitystreams#Create") to { CreateImpl() },
URI.create("https://www.w3.org/ns/activitystreams#Person") to { PersonImpl() },
URI.create("https://www.w3.org/ns/activitystreams#Note") to { NoteImpl() },
)
fun factory(uri: URI): JsonLd? {