-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebe0e09
commit 60dc36b
Showing
4 changed files
with
161 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 file contains 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
35 changes: 35 additions & 0 deletions
35
sdccc/src/main/java/com/draeger/medical/sdccc/messages/OrderedStreamIterator.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.draeger.medical.sdccc.messages | ||
|
||
import org.hibernate.query.spi.CloseableIterator | ||
import org.hibernate.query.spi.ScrollableResultsImplementor | ||
|
||
/** | ||
* Iterator to be used to create Streams with the ORDERED characteristic from ScrollableResults. | ||
*/ | ||
class OrderedStreamIterator<T>(private val results: ScrollableResultsImplementor) : CloseableIterator<T> { | ||
|
||
override fun close() { | ||
results.close() | ||
} | ||
|
||
override fun remove() { | ||
error("not yet implemented!") | ||
} | ||
|
||
override fun hasNext(): Boolean { | ||
if (results.isClosed) { | ||
return false | ||
} | ||
return results.next() | ||
} | ||
|
||
override fun next(): T { | ||
val element = results.get() | ||
@Suppress("UNCHECKED_CAST") | ||
return if (element.size == 1) { | ||
element[0] | ||
} else { | ||
element | ||
} as T | ||
} | ||
} |
This file contains 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