8000 style(dsl): sort members in `OutboundEnvelope` by DanySK · Pull Request #943 · Collektive/collektive · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

style(dsl): sort members in OutboundEnvelope #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
*/
fun <Value> addData(path: Path, data: SharedData<ID, Value>, dataSharingMethod: DataSharingMethod<Value>)

/**
* Extract the message for the [receiverId] through the given [factory].
*
* One the [OutboundEnvelope] is created, this method extracts the message to send to the [receiverId].
*/
fun prepareMessageFor(receiverId: ID, factory: MessageFactory<ID, *> = InMemoryMessageFactory()): Message<ID, Any?>

/**
* Returns `true` if the envelope is empty.
*/
Expand All @@ -47,6 +40,13 @@
*/
fun isNotEmpty(): Boolean

/**
* Extract the message for the [receiverId] through the given [factory].
*
* One the [OutboundEnvelope] is created, this method extracts the message to send to the [receiverId].
*/
fun prepareMessageFor(receiverId: ID, factory: MessageFactory<ID, *> = InMemoryMessageFactory()): Message<ID, Any?>

Check warning on line 48 in collektive-dsl/src/commonMain/kotlin/it/unibo/collektive/networking/OutboundEnvelope.kt

View check run for this annotation

Codecov / codecov/patch

collektive-dsl/src/commonMain/kotlin/it/unibo/collektive/networking/OutboundEnvelope.kt#L48

Added line #L48 was not covered by tests

/**
* Utilities for [OutboundEnvelope].
*/
Expand All @@ -56,6 +56,7 @@
*/
internal operator fun <ID : Any> invoke(senderId: ID, expectedSize: Int): OutboundEnvelope<ID> =
object : OutboundEnvelope<ID> {

private val defaults: MutableMap<Path, PayloadRepresentation<Any?>> = LinkedHashMap(expectedSize * 2)
private val overrides: MutableMap<ID, MutableList<Pair<Path, PayloadRepresentation<Any?>>>> =
LinkedHashMap(expectedSize * 2)
Expand All @@ -79,6 +80,10 @@
}
}

override fun isEmpty(): Boolean = defaults.isEmpty()

Check warning on line 83 in collektive-dsl/src/commonMain/kotlin/it/unibo/collektive/networking/OutboundEnvelope.kt

View check run for this annotation

Codecov / codecov/patch

collektive-dsl/src/commonMain/kotlin/it/unibo/collektive/networking/OutboundEnvelope.kt#L83

Added line #L83 was not covered by tests

override fun isNotEmpty(): Boolean = defaults.isNotEmpty()

override fun prepareMessageFor(receiverId: ID, factory: MessageFactory<ID, *>): Message<ID, Any?> {
val overridesForId = overrides[receiverId].orEmpty()
val payloads = when {
Expand All @@ -87,10 +92,6 @@
}
return factory(senderId, payloads)
}

override fun isEmpty(): Boolean = defaults.isEmpty()

override fun isNotEmpty(): Boolean = defaults.isNotEmpty()
}
}
}
Loading
0