feat: Kotlinのオブジェクトに詰め込む部分を作成
This commit is contained in:
parent
722ad284b0
commit
3538e9e973
|
@ -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>
|
|
@ -4,8 +4,8 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleHome" value="" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
@ -13,5 +13,6 @@
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="parallelModelFetch" value="true" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -4,7 +4,7 @@
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -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) }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 =
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package dev.usbharu.activitystreams.impl.model.`object`
|
package dev.usbharu.activitystreams.impl.model.`object`
|
||||||
|
|
||||||
import dev.usbharu.activitystreams.model.ImageOrLink
|
import dev.usbharu.activitystreams.model.ImageOrLink
|
||||||
|
import dev.usbharu.activitystreams.model.JsonLdWrapper
|
||||||
import dev.usbharu.activitystreams.model.ObjectOrLink
|
import dev.usbharu.activitystreams.model.ObjectOrLink
|
||||||
import dev.usbharu.activitystreams.model.UriOrLink
|
import dev.usbharu.activitystreams.model.UriOrLink
|
||||||
import dev.usbharu.activitystreams.model.core.Collection
|
import dev.usbharu.activitystreams.model.core.Collection
|
||||||
|
@ -12,34 +13,35 @@ import java.time.Duration
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
class NoteImpl(
|
class NoteImpl(
|
||||||
override var type: List<URI>,
|
override var type: List<URI> = emptyList(),
|
||||||
override var attachment: List<ObjectOrLink>,
|
override var attachment: List<ObjectOrLink> = emptyList(),
|
||||||
override var attributedTo: List<ObjectOrLink>,
|
override var attributedTo: List<ObjectOrLink> = emptyList(),
|
||||||
override var audience: List<ObjectOrLink>,
|
override var audience: List<ObjectOrLink> = emptyList(),
|
||||||
override var content: LangString?,
|
override var content: LangString? = null,
|
||||||
override var context: List<ObjectOrLink>,
|
override var context: List<ObjectOrLink> = emptyList(),
|
||||||
override var name: LangString?,
|
override var name: LangString? = null,
|
||||||
override var endTime: OffsetDateTime?,
|
override var endTime: JsonLdWrapper<OffsetDateTime>? = null,
|
||||||
override var generator: List<ObjectOrLink>,
|
override var generator: List<ObjectOrLink> = emptyList(),
|
||||||
override var icon: List<ImageOrLink>,
|
override var icon: List<ImageOrLink> = emptyList(),
|
||||||
override var image: List<ImageOrLink>,
|
override var image: List<ImageOrLink> = emptyList(),
|
||||||
override var inReplyTo: List<ObjectOrLink>,
|
override var inReplyTo: List<ObjectOrLink> = emptyList(),
|
||||||
override var location: ObjectOrLink?,
|
override var location: ObjectOrLink? = null,
|
||||||
override var preview: ObjectOrLink?,
|
override var preview: ObjectOrLink? = null,
|
||||||
override var published: OffsetDateTime?,
|
override var published: JsonLdWrapper<OffsetDateTime>? = null,
|
||||||
override var replies: Collection?,
|
override var replies: Collection? = null,
|
||||||
override var startTime: OffsetDateTime?,
|
override var startTime: JsonLdWrapper<OffsetDateTime>? = null,
|
||||||
override var summary: LangString?,
|
override var summary: LangString? = null,
|
||||||
override var tag: List<ObjectOrLink>,
|
override var tag: List<ObjectOrLink> = emptyList(),
|
||||||
override var updated: OffsetDateTime?,
|
override var updated: JsonLdWrapper<OffsetDateTime>? = null,
|
||||||
override var url: List<UriOrLink>,
|
override var url: List<UriOrLink> = emptyList(),
|
||||||
override var to: List<ObjectOrLink>,
|
override var to: List<ObjectOrLink> = emptyList(),
|
||||||
override var bto: List<ObjectOrLink>,
|
override var bto: List<ObjectOrLink> = emptyList(),
|
||||||
override var cc: List<ObjectOrLink>,
|
override var cc: List<ObjectOrLink> = emptyList(),
|
||||||
override var bcc: List<ObjectOrLink>,
|
override var bcc: List<ObjectOrLink> = emptyList(),
|
||||||
override var mediaType: MimeMediaType?,
|
override var mediaType: MimeMediaType? = null,
|
||||||
override var duration: Duration?,
|
override var duration: JsonLdWrapper<Duration>? = null,
|
||||||
override var id: URI?,
|
override var id: URI? = null,
|
||||||
override var source: ObjectOrLink?
|
override var source: ObjectOrLink? = null,
|
||||||
|
override var value: Any? = null,
|
||||||
) : Note {
|
) : Note {
|
||||||
}
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package dev.usbharu.activitystreams.impl.type
|
||||||
|
|
||||||
|
class BuilderContext {
|
||||||
|
fun <T> getBuilder():JsonObjectBuilder<T>{
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
}
|
|
@ -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を自動で呼び出す部分を作る
|
|
@ -1,13 +1,17 @@
|
||||||
package dev.usbharu.activitystreams.impl.type
|
package dev.usbharu.activitystreams.impl.type
|
||||||
|
|
||||||
import dev.usbharu.activitystreams.impl.model.activity.CreateImpl
|
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 dev.usbharu.activitystreams.model.JsonLd
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
class TypeFactory {
|
class TypeFactory {
|
||||||
|
|
||||||
val map = mutableMapOf<URI, () -> JsonLd>(
|
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? {
|
fun factory(uri: URI): JsonLd? {
|
||||||
|
|
Loading…
Reference in New Issue