mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Turn output classes into Kotlin data classes
This commit is contained in:
@@ -4,11 +4,14 @@ import org.briarproject.bramble.api.identity.Author
|
|||||||
import javax.annotation.concurrent.Immutable
|
import javax.annotation.concurrent.Immutable
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@Suppress("unused")
|
data class OutputAuthor(
|
||||||
class OutputAuthor(author: Author) {
|
val id: ByteArray,
|
||||||
|
val name: String,
|
||||||
val id: ByteArray = author.id.bytes
|
val publicKey: ByteArray
|
||||||
val name: String = author.name
|
) {
|
||||||
val publicKey: ByteArray = author.publicKey
|
constructor(author: Author) : this(
|
||||||
|
id = author.id.bytes,
|
||||||
|
name = author.name,
|
||||||
|
publicKey = author.publicKey
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,28 @@ import org.briarproject.briar.headless.output
|
|||||||
import javax.annotation.concurrent.Immutable
|
import javax.annotation.concurrent.Immutable
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@Suppress("unused")
|
internal data class OutputBlogPost(
|
||||||
internal class OutputBlogPost(header: BlogPostHeader, val body: String) {
|
val body: String,
|
||||||
|
val author: OutputAuthor,
|
||||||
val author: OutputAuthor = OutputAuthor(header.author)
|
val authorStatus: String,
|
||||||
val authorStatus: String = header.authorStatus.output()
|
val type: String,
|
||||||
val type = header.type.output()
|
val id: ByteArray,
|
||||||
val id: ByteArray = header.id.bytes
|
val parentId: ByteArray?,
|
||||||
val parentId = header.parentId?.bytes
|
val read: Boolean,
|
||||||
val read = header.isRead
|
val rssFeed: Boolean,
|
||||||
val rssFeed = header.isRssFeed
|
val timestamp: Long,
|
||||||
val timestamp = header.timestamp
|
val timestampReceived: Long
|
||||||
val timestampReceived = header.timeReceived
|
) {
|
||||||
|
internal constructor(header: BlogPostHeader, body: String) : this(
|
||||||
|
body = body,
|
||||||
|
author = OutputAuthor(header.author),
|
||||||
|
authorStatus = header.authorStatus.output(),
|
||||||
|
type = header.type.output(),
|
||||||
|
id = header.id.bytes,
|
||||||
|
parentId = header.parentId?.bytes,
|
||||||
|
read = header.isRead,
|
||||||
|
rssFeed = header.isRssFeed,
|
||||||
|
timestamp = header.timestamp,
|
||||||
|
timestampReceived = header.timeReceived
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package org.briarproject.briar.headless.contact
|
package org.briarproject.briar.headless.contact
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.Contact
|
import org.briarproject.bramble.api.contact.Contact
|
||||||
|
import org.briarproject.bramble.identity.OutputAuthor
|
||||||
import org.briarproject.briar.headless.output
|
import org.briarproject.briar.headless.output
|
||||||
import javax.annotation.concurrent.Immutable
|
import javax.annotation.concurrent.Immutable
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@Suppress("unused")
|
internal data class OutputContact(
|
||||||
internal class OutputContact(c: Contact) {
|
val id: Int,
|
||||||
|
val author: OutputAuthor,
|
||||||
val id = c.id.int
|
val verified: Boolean
|
||||||
val author = c.author.output()
|
) {
|
||||||
val verified = c.isVerified
|
internal constructor(c: Contact) : this(
|
||||||
|
id = c.id.int,
|
||||||
|
author = c.author.output(),
|
||||||
|
verified = c.isVerified
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import org.briarproject.briar.api.forum.Forum
|
|||||||
import javax.annotation.concurrent.Immutable
|
import javax.annotation.concurrent.Immutable
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@Suppress("unused")
|
internal class OutputForum(
|
||||||
internal class OutputForum(forum: Forum) {
|
val name: String,
|
||||||
|
val id: ByteArray
|
||||||
val name: String = forum.name
|
) {
|
||||||
val id: ByteArray = forum.id.bytes
|
constructor(forum: Forum) : this(
|
||||||
|
name = forum.name,
|
||||||
|
id = forum.id.bytes
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,43 +6,41 @@ import org.briarproject.briar.api.messaging.PrivateMessageHeader
|
|||||||
import javax.annotation.concurrent.Immutable
|
import javax.annotation.concurrent.Immutable
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
internal data class OutputPrivateMessage(
|
||||||
internal class OutputPrivateMessage {
|
val body: String,
|
||||||
|
val timestamp: Long,
|
||||||
val body: String
|
val read: Boolean,
|
||||||
val timestamp: Long
|
val seen: Boolean,
|
||||||
val read: Boolean
|
val sent: Boolean,
|
||||||
val seen: Boolean
|
val local: Boolean,
|
||||||
val sent: Boolean
|
val id: ByteArray,
|
||||||
val local: Boolean
|
val groupId: ByteArray,
|
||||||
val id: ByteArray
|
|
||||||
val groupId: ByteArray
|
|
||||||
val contactId: Int
|
val contactId: Int
|
||||||
|
) {
|
||||||
internal constructor(header: PrivateMessageHeader, contactId: ContactId, body: String) {
|
internal constructor(header: PrivateMessageHeader, contactId: ContactId, body: String) : this(
|
||||||
this.body = body
|
body = body,
|
||||||
this.timestamp = header.timestamp
|
timestamp = header.timestamp,
|
||||||
this.read = header.isRead
|
read = header.isRead,
|
||||||
this.seen = header.isSeen
|
seen = header.isSeen,
|
||||||
this.sent = header.isSent
|
sent = header.isSent,
|
||||||
this.local = header.isLocal
|
local = header.isLocal,
|
||||||
this.id = header.id.bytes
|
id = header.id.bytes,
|
||||||
this.groupId = header.groupId.bytes
|
groupId = header.groupId.bytes,
|
||||||
this.contactId = contactId.int
|
contactId = contactId.int
|
||||||
}
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only meant for own [PrivateMessage]s directly after creation.
|
* Only meant for own [PrivateMessage]s directly after creation.
|
||||||
*/
|
*/
|
||||||
internal constructor(m: PrivateMessage, contactId: ContactId, body: String) {
|
internal constructor(m: PrivateMessage, contactId: ContactId, body: String) : this(
|
||||||
this.body = body
|
body = body,
|
||||||
this.timestamp = m.message.timestamp
|
timestamp = m.message.timestamp,
|
||||||
this.read = true
|
read = true,
|
||||||
this.seen = true
|
seen = true,
|
||||||
this.sent = false
|
sent = true,
|
||||||
this.local = true
|
local = true,
|
||||||
this.id = m.message.id.bytes
|
id = m.message.id.bytes,
|
||||||
this.groupId = m.message.groupId.bytes
|
groupId = m.message.groupId.bytes,
|
||||||
this.contactId = contactId.int
|
contactId = contactId.int
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user