Repo created
This commit is contained in:
parent
75dc487a7a
commit
39c29d175b
6317 changed files with 388324 additions and 2 deletions
7
core/architecture/api/build.gradle.kts
Normal file
7
core/architecture/api/build.gradle.kts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
plugins {
|
||||
id(ThunderbirdPlugins.Library.kmp)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "net.thunderbird.core.architecture"
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package net.thunderbird.core.architecture.data
|
||||
|
||||
/**
|
||||
* Mapper definition for converting between domain models and data transfer objects (DTOs).
|
||||
*
|
||||
* @param TDomain The domain model type.
|
||||
* @param TDto The data transfer object type.
|
||||
*/
|
||||
interface DataMapper<TDomain, TDto> {
|
||||
fun toDomain(dto: TDto): TDomain
|
||||
fun toDto(domain: TDomain): TDto
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package net.thunderbird.core.architecture.model
|
||||
|
||||
import kotlin.uuid.ExperimentalUuidApi
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
* Abstract base for ID factories.
|
||||
*
|
||||
* This class provides a default implementation for creating and generating IDs.
|
||||
* It uses UUIDs as the underlying representation of the ID.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```kotlin
|
||||
* class AccountIdFactory : BaseIdFactory<AccountId>()
|
||||
* ```
|
||||
*
|
||||
* @param T The type of the ID.
|
||||
*/
|
||||
@OptIn(ExperimentalUuidApi::class)
|
||||
abstract class BaseIdFactory<T> : IdFactory<T> {
|
||||
override fun of(raw: String): Id<T> = Id(Uuid.parse(raw))
|
||||
|
||||
override fun create(): Id<T> = Id(Uuid.random())
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package net.thunderbird.core.architecture.model
|
||||
|
||||
import kotlin.uuid.ExperimentalUuidApi
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
* Represents a unique identifier for an entity.
|
||||
*
|
||||
* @param T The type of the entity.
|
||||
*
|
||||
* @property value The underlying UUID value.
|
||||
*/
|
||||
@OptIn(ExperimentalUuidApi::class)
|
||||
@JvmInline
|
||||
value class Id<T>(val value: Uuid) {
|
||||
|
||||
/**
|
||||
* Returns the raw string representation of the ID.
|
||||
*/
|
||||
fun asRaw(): String {
|
||||
return value.toString()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package net.thunderbird.core.architecture.model
|
||||
|
||||
/**
|
||||
* Factory interface for creating and generating IDs.
|
||||
*/
|
||||
interface IdFactory<T> {
|
||||
|
||||
/**
|
||||
* Creates an [Id] from a raw string representation.
|
||||
*
|
||||
* @param raw The raw string representation of the ID.
|
||||
* @return An instance of [Id] representing the ID.
|
||||
*/
|
||||
fun of(raw: String): Id<T>
|
||||
|
||||
/**
|
||||
* Creates a new [Id].
|
||||
*
|
||||
* @return A new instance of [Id] representing the created ID.
|
||||
*/
|
||||
fun create(): Id<T>
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package net.thunderbird.core.architecture.model
|
||||
|
||||
/**
|
||||
* Interface representing an entity with a unique identifier.
|
||||
*/
|
||||
interface Identifiable<T> {
|
||||
val id: Id<T>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue