From e85cdf9445f22a7e1dfdb741f5bc35d3b37994c3 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 10 Jan 2025 21:41:54 +0100 Subject: [PATCH] Add allowsReading and allowsWriting methods --- .../base/implementable/stream/Stream.kt | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/base/src/main/kotlin/de/staropensource/engine/base/implementable/stream/Stream.kt b/base/src/main/kotlin/de/staropensource/engine/base/implementable/stream/Stream.kt index 137a610..8d2fed2 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/implementable/stream/Stream.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/implementable/stream/Stream.kt @@ -700,7 +700,33 @@ abstract class Stream( * * @since v1-alpha10 */ - READ_WRITE, + READ_WRITE; + + /** + * Returns whether this mode + * allows stream reading. + * + * @return allows reading? + * @since v1-alpha10 + */ + fun allowsReading(): Boolean = when(this) { + READ -> true + WRITE -> false + READ_WRITE -> true + } + + /** + * Returns whether this mode + * allows stream reading. + * + * @return allows reading? + * @since v1-alpha10 + */ + fun allowsWriting(): Boolean = when(this) { + READ -> false + WRITE -> true + READ_WRITE -> true + } } /**