Last active
April 29, 2016 13:49
-
-
Save frgomes/7e38d9a30b31792a44a9791b766b93f7 to your computer and use it in GitHub Desktop.
Scala - Dynamically mixin a trait to an instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** This is a marker trait intended to provide independence of FIX version. */ | |
| trait SecurityListLike extends quickfix.Message | |
| object SecurityListLike { | |
| implicit def mixin(o: Mixin) = o.o | |
| def ::(o: quickfix.Message) = new Mixin(o) | |
| final class Mixin private[SecurityListLike](val o: quickfix.Message) extends SecurityListLike { | |
| import quickfix.field.MsgType | |
| require(o.getHeader.getString(MsgType.FIELD) == MsgType.SECURITY_LIST) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
val message: quickfix.Message = getMessageFromSomewhere
val x: SecurityListLike = message :: SecurityListLike