Skip to content
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

FDP-2758: New SignableMessageWrapper that doesn't need subclassing #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sanderv
Copy link
Contributor

@sanderv sanderv commented Nov 4, 2024

No description provided.

abstract class SignableMessageWrapper<T>(val message: T) {
class SignableMessageWrapper<T>(
val message: T,
private val messageGetter: Function<T, ByteBuffer>,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not use the java.util.function interfaces but the Kotlin syntax ((T) -> ByteBuffer in this case)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can then be invoked using .invoke(..) or just (...)


/** @param signature The signature in ByteBuffer form to be set on the message */
abstract fun setSignature(signature: ByteBuffer?)
fun setSignature(signature: ByteBuffer?) {
signatureSetter.accept(signature)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, message is not used (and it becomes the responsibility of the invoker to use the same message).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The signature of the setter parameter would then become (T, ByteBuffer?) -> Unit

@@ -34,11 +33,12 @@ class MessageSignerTest {

@Test
fun signsMessageWithoutSignature() {
val messageWrapper: SignableMessageWrapper<*> = this.messageWrapper()
val messageWrapper: SignableMessageWrapper<TestableMessage> = this.messageWrapper()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this. is unnecessary here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old formatter left overs. Remove all the this's!

override fun getSignature(): ByteBuffer? {
return this.signature
}
fun getSigBytes(): ByteBuffer? = this.signature
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this. is not needed

Kotlin notation
removed `this.`

Signed-off-by: Sander Verbruggen <[email protected]>
Signed-off-by: Sander Verbruggen <[email protected]>
Copy link

sonarqubecloud bot commented Nov 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants