-
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.
Merge branch 'Draegerwerk:main' into sdccc-gradle
- Loading branch information
Showing
15 changed files
with
328 additions
and
129 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
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
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
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
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the MIT License. | ||
* Copyright (c) 2023-2024 Draegerwerk AG & Co. KGaA. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
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() { | ||
throw UnsupportedOperationException( | ||
"this stream does not support the" + | ||
" remove operation" | ||
) | ||
} | ||
|
||
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 | ||
} | ||
} |
Oops, something went wrong.