mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 04:17:59 +01:00
Add SignatureSubpacketCallback.then()
This commit is contained in:
parent
54a9b4f258
commit
f611f54cad
1 changed files with 20 additions and 0 deletions
|
@ -23,4 +23,24 @@ interface SignatureSubpacketCallback<S : BaseSignatureSubpackets> {
|
||||||
fun modifyUnhashedSubpackets(unhashedSubpackets: S) {
|
fun modifyUnhashedSubpackets(unhashedSubpackets: S) {
|
||||||
// Empty default implementation to allow for cleaner overriding
|
// Empty default implementation to allow for cleaner overriding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new [SignatureSubpacketCallback] which first applies the current callback instance,
|
||||||
|
* followed by the passed in [nextCallback].
|
||||||
|
* This is useful to composite different [SignatureSubpacketCallback] instances.
|
||||||
|
*/
|
||||||
|
fun then(nextCallback: SignatureSubpacketCallback<S>): SignatureSubpacketCallback<S> {
|
||||||
|
val currCallback = this
|
||||||
|
return object : SignatureSubpacketCallback<S> {
|
||||||
|
override fun modifyHashedSubpackets(hashedSubpackets: S) {
|
||||||
|
currCallback.modifyHashedSubpackets(hashedSubpackets)
|
||||||
|
nextCallback.modifyHashedSubpackets(hashedSubpackets)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun modifyUnhashedSubpackets(unhashedSubpackets: S) {
|
||||||
|
currCallback.modifyUnhashedSubpackets(unhashedSubpackets)
|
||||||
|
nextCallback.modifyUnhashedSubpackets(unhashedSubpackets)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue