Improved 'owner' property in corresponding states
This commit is contained in:
parent
ad87bb7904
commit
826f286404
@ -5,12 +5,23 @@ package ru.landgrafhomyak.utility.closeable_state_1
|
|||||||
import kotlin.contracts.ExperimentalContracts
|
import kotlin.contracts.ExperimentalContracts
|
||||||
|
|
||||||
public class OwnedErrorOnConcurrentAccessState : ErrorOnConcurrentAccessState {
|
public class OwnedErrorOnConcurrentAccessState : ErrorOnConcurrentAccessState {
|
||||||
public val _owner: Any
|
private var _owner: Any?
|
||||||
|
|
||||||
|
public constructor() : super() {
|
||||||
|
this._owner = null
|
||||||
|
}
|
||||||
|
|
||||||
public constructor(owner: Any) : super() {
|
public constructor(owner: Any) : super() {
|
||||||
this._owner = owner
|
this._owner = owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var owner: Any
|
||||||
|
get() = this._owner ?: throw IllegalStateException("Owner not set yet")
|
||||||
|
set(value) {
|
||||||
|
if (this._owner != null) throw IllegalStateException("Owner already initialized")
|
||||||
|
this._owner = value
|
||||||
|
}
|
||||||
|
|
||||||
override fun throwClosed(): Nothing {
|
override fun throwClosed(): Nothing {
|
||||||
throw IllegalStateException("Object is closed: ${this._owner}")
|
throw IllegalStateException("Object is closed: ${this._owner}")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,12 +5,23 @@ package ru.landgrafhomyak.utility.closeable_state_1
|
|||||||
import kotlin.contracts.ExperimentalContracts
|
import kotlin.contracts.ExperimentalContracts
|
||||||
|
|
||||||
public class OwnedUsagesCounter : UsagesCounter {
|
public class OwnedUsagesCounter : UsagesCounter {
|
||||||
public val _owner: Any
|
private var _owner: Any?
|
||||||
|
|
||||||
|
public constructor() : super() {
|
||||||
|
this._owner = null
|
||||||
|
}
|
||||||
|
|
||||||
public constructor(owner: Any) : super() {
|
public constructor(owner: Any) : super() {
|
||||||
this._owner = owner
|
this._owner = owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var owner: Any
|
||||||
|
get() = this._owner ?: throw IllegalStateException("Owner not set yet")
|
||||||
|
set(value) {
|
||||||
|
if (this._owner != null) throw IllegalStateException("Owner already initialized")
|
||||||
|
this._owner = value
|
||||||
|
}
|
||||||
|
|
||||||
override fun throwClosed(): Nothing {
|
override fun throwClosed(): Nothing {
|
||||||
throw IllegalStateException("Object is closed: ${this._owner}")
|
throw IllegalStateException("Object is closed: ${this._owner}")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user