Created
August 2, 2018 18:25
-
-
Save schroedermatt/de498c3cf3c82a781799a82758499295 to your computer and use it in GitHub Desktop.
toStruct extension example
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
| // extension on model from 3rd party library | |
| fun ArtistModel.toStruct() : Struct = Struct(Artist.SCHEMA) | |
| .put(BaseSchema.HREF_FIELD, this.href) | |
| .put(BaseSchema.ID_FIELD, this.id) | |
| .put(BaseSchema.NAME_FIELD, this.name) | |
| // example when creating list of SourceRecords from result set | |
| val results: List<ArtistModel> = client.getResults() | |
| results.map { | |
| SourceRecord(partition, offset, topic, keySchema, it.id, valueSchema, it.toStruct()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment