package net.pterodactylus.sone.data
+import net.pterodactylus.sone.database.PostBuilder
import java.util.Comparator.comparing
/**
*/
@get:JvmName("newestPostFirst")
val newestPostFirst: Comparator<Post> = comparing(Post::getTime).reversed()
+
+data class PostShell(val id: String, val soneId: String, val recipientId: String?, val time: Long, val text: String) {
+
+ fun build(postBuilder: PostBuilder) =
+ postBuilder.withId(id).from(soneId).let { if (recipientId != null) it.to(recipientId) else it }.withTime(time).withText(text).build()
+
+}
+
+fun Post.toShell() = PostShell(id, sone!!.id, recipient.orNull()?.id, time, text)
package net.pterodactylus.sone.data
+import net.pterodactylus.sone.database.PostReplyBuilder
import java.util.Comparator.comparing
/**
*/
val noFutureReply: (Reply<*>) -> Boolean =
{ it.getTime() <= System.currentTimeMillis() }
+
+data class PostReplyShell(val id: String, val soneId: String, val postId: String, val time: Long, val text: String) {
+
+ fun build(postReplyBuilder: PostReplyBuilder): PostReply {
+ return postReplyBuilder.withId(id).from(soneId).to(postId).withTime(time).withText(text).build()
+ }
+
+}
+
+fun PostReply.toShell() = PostReplyShell(id, sone.id, postId, time, text)
import net.pterodactylus.sone.data.Image
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
+import net.pterodactylus.sone.data.PostReplyShell
+import net.pterodactylus.sone.data.PostShell
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.data.allAlbums
import net.pterodactylus.sone.data.allImages
import net.pterodactylus.sone.data.impl.AlbumBuilderImpl
import net.pterodactylus.sone.data.impl.ImageBuilderImpl
import net.pterodactylus.sone.data.newestReplyFirst
+import net.pterodactylus.sone.data.toShell
import net.pterodactylus.sone.database.AlbumBuilder
import net.pterodactylus.sone.database.Database
import net.pterodactylus.sone.database.DatabaseException
private val writeLock: WriteLock by lazy { lock.writeLock() }
private val configurationLoader = ConfigurationLoader(configuration)
private val allSones = mutableMapOf<String, Sone>()
- private val allPosts = mutableMapOf<String, MemoryPost.Shell>()
- private val sonePosts: Multimap<String, MemoryPost.Shell> = HashMultimap.create<String, MemoryPost.Shell>()
+ private val allPosts = mutableMapOf<String, PostShell>()
+ private val sonePosts: Multimap<String, PostShell> = HashMultimap.create<String, PostShell>()
private val knownPosts = mutableSetOf<String>()
- private val allPostReplies = mutableMapOf<String, MemoryPostReply.Shell>()
+ private val allPostReplies = mutableMapOf<String, PostReplyShell>()
private val sonePostReplies: Multimap<String, PostReply> = TreeMultimap.create<String, PostReply>(Comparator { leftString, rightString -> leftString.compareTo(rightString) }, newestReplyFirst)
private val knownPostReplies = mutableSetOf<String>()
private val allAlbums = mutableMapOf<String, Album>()
package net.pterodactylus.sone.database.memory
import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.data.PostShell
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.database.PostBuilder
import net.pterodactylus.sone.database.SoneProvider
override fun toString() = "${javaClass.name}[id=$id,sone=$soneId,recipient=$recipientId,time=$time,text=$text]"
- data class Shell(val id: String, val soneId: String, val recipientId: String?, val time: Long, val text: String) {
-
- fun build(postBuilder: PostBuilder) =
- postBuilder.withId(id).from(soneId).let { if (recipientId != null) it.to(recipientId) else it }.withTime(time).withText(text).build()
-
- }
-
}
-
-fun Post.toShell() = MemoryPost.Shell(id, sone!!.id, recipient.orNull()?.id, time, text)
import com.google.common.base.Optional
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
+import net.pterodactylus.sone.data.PostReplyShell
import net.pterodactylus.sone.database.PostReplyBuilder
import net.pterodactylus.sone.database.SoneProvider
import net.pterodactylus.sone.utils.asOptional
'}'
}
- class Shell(val id: String, val soneId: String, val postId: String, val time: Long, val text: String) {
-
- fun build(postReplyBuilder: PostReplyBuilder): PostReply {
- return postReplyBuilder.withId(id).from(soneId).to(postId).withTime(time).withText(text).build()
- }
-
- }
-
}
-
-fun PostReply.toShell() = MemoryPostReply.Shell(id, sone.id, postId, time, text)