Removed 'throw*' methods

This commit is contained in:
Andrew Golovashevich 2025-08-24 00:10:33 +03:00
parent 05b9fc6078
commit ed06e6c2a0
5 changed files with 7 additions and 22 deletions

View File

@ -15,12 +15,6 @@ public sealed class ChildCloseableState<T : CloseableState> : CloseableState {
this._state = state
}
override fun throwClosed(): Nothing =
this._state.throwClosed()
override fun throwInUse(): Nothing =
this._state.throwInUse()
override fun assertNotClosed(): Unit =
this._state.assertNotClosed()

View File

@ -1,9 +1,6 @@
package ru.landgrafhomyak.utility.closeable_state_1
public interface CloseableState : AutoCloseable {
public fun throwClosed(): Nothing
public fun throwInUse(): Nothing
public interface CloseableState {
public fun assertNotClosed()
public val isClosed: Boolean
@ -15,7 +12,7 @@ public interface CloseableState : AutoCloseable {
public fun finishUsage()
@ManualStateManipulation
public override fun close()
public fun close()
public interface AllowsConcurrency : CloseableState {

View File

@ -8,12 +8,6 @@ public class CloseableStateCloseableWrapper(
override val isInUse: Boolean by this._self::isInUse
override val isClosed: Boolean by this._self::isInUse
override fun throwClosed(): Nothing =
this._self.throwClosed()
override fun throwInUse(): Nothing =
this._self.throwInUse()
override fun assertNotClosed(): Unit =
this._self.assertNotClosed()

View File

@ -15,15 +15,15 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr
public final override val isInUse: Boolean
get() = this._state.get() === State.IN_USE
public open override fun throwClosed(): Nothing {
protected open fun throwClosed(): Nothing {
throw IllegalStateException("Object is closed")
}
public open override fun throwInUse(): Nothing {
protected open fun throwInUse(): Nothing {
throw IllegalStateException("Failed close object because it is in use")
}
public open fun throwConcurrent(): Nothing {
protected open fun throwConcurrent(): Nothing {
throw IllegalStateException("Object is in use by another thread")
}

View File

@ -17,11 +17,11 @@ public open class UsagesCounter : CloseableState.AllowsConcurrency {
public fun getCurrentUsagesCount(): Long = this._value.get()
public open override fun throwClosed(): Nothing {
protected open fun throwClosed(): Nothing {
throw IllegalStateException("Object is closed")
}
public open override fun throwInUse(): Nothing {
protected open fun throwInUse(): Nothing {
throw IllegalStateException("Failed close object because it is in use")
}