-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
76 additions
and
14 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app/src/main/java/dev/arkbuilders/arkmemo/models/VersionsResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/dev/arkbuilders/arkmemo/repo/versions/RootVersionsStorage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.arkbuilders.arkmemo.repo.versions | ||
|
||
import dev.arkbuilders.arklib.ResourceId | ||
import dev.arkbuilders.arklib.arkFolder | ||
import dev.arkbuilders.arklib.data.storage.FileStorage | ||
import kotlinx.coroutines.CoroutineScope | ||
import space.taran.arkmemo.utils.arkVersions | ||
import java.nio.file.Path | ||
|
||
class RootVersionsStorage( | ||
private val scope: CoroutineScope, | ||
private val root: Path | ||
): | ||
FileStorage<Versions>("versions", scope, root.arkFolder().arkVersions(), VersionsMonoid), | ||
VersionsStorage { | ||
|
||
override fun valueFromString(raw: String): Versions = | ||
raw.split(",").filter { it.isNotEmpty() }.map { | ||
ResourceId.fromString(it) | ||
}.toSet() | ||
|
||
override fun valueToString(value: Versions): String = value.joinToString(",") | ||
} |
4 changes: 3 additions & 1 deletion
4
...dev/arkbuilders/arkmemo/models/Version.kt → ...builders/arkmemo/repo/versions/Version.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/dev/arkbuilders/arkmemo/repo/versions/Versions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.arkbuilders.arkmemo.repo.versions | ||
|
||
import android.util.Log | ||
import dev.arkbuilders.arklib.ResourceId | ||
import dev.arkbuilders.arklib.data.storage.Monoid | ||
|
||
typealias Versions = Set<ResourceId> | ||
|
||
object VersionsMonoid : Monoid<Versions> { | ||
|
||
override val neutral: Versions = setOf() | ||
|
||
override fun combine(a: Versions, b: Versions): Versions { | ||
val result = a.union(b) | ||
Log.d(LOG_PREFIX, "merging $a and $b into $result") | ||
return result | ||
} | ||
} | ||
|
||
internal val LOG_PREFIX: String = "[versions]" |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/dev/arkbuilders/arkmemo/repo/versions/VersionsStorage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.arkbuilders.arkmemo.repo.versions | ||
|
||
import dev.arkbuilders.arklib.ResourceId | ||
import dev.arkbuilders.arklib.data.storage.Storage | ||
|
||
interface VersionsStorage: Storage<Versions> { | ||
|
||
fun setParents(child: ResourceId, parents: Versions) = setValue(child, parents) | ||
|
||
fun getParents(child: ResourceId): Versions = getValue(child) | ||
|
||
fun removeParents(child: ResourceId) { | ||
remove(child) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/dev/arkbuilders/arkmemo/repo/versions/VersionsStorageRepo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package dev.arkbuilders.arkmemo.repo.versions | ||
|
||
class VersionsStorageRepo { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
app/src/test/java/dev/arkbuilders/arkmemo/VersionStorageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters