-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sander Verbruggen <[email protected]>
abstract class SignableMessageWrapper<T>(val message: T) { | ||
class SignableMessageWrapper<T>( | ||
val message: T, | ||
private val messageGetter: Function<T, ByteBuffer>, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.
is unnecessary here
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]>
Signed-off-by: Sander Verbruggen <[email protected]>
Quality Gate passedIssues Measures |
No description provided.