Simplify extensions.kt

This commit is contained in:
Iaroslav Postovalov 2020-10-12 23:42:13 +07:00
parent 4bf430b2c0
commit 06c3ce5aaf
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7

View File

@ -1,22 +1,12 @@
package kscience.kmath.ast
import kscience.kmath.operations.Algebra
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
/**
* Stores `provideDelegate` method returning property of [MST.Symbolic].
* Returns [PropertyDelegateProvider] providing [ReadOnlyProperty] of [MST.Symbolic] with its value equal to the name
* of the property.
*/
public object MstSymbolDelegateProvider {
/**
* Returns [ReadOnlyProperty] of [MST.Symbolic] with its value equal to the name of the property.
*/
public operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty<Any?, MST.Symbolic> =
ReadOnlyProperty { _, property -> MST.Symbolic(property.name) }
}
/**
* Returns [MstSymbolDelegateProvider].
*/
public val Algebra<MST>.symbol: MstSymbolDelegateProvider
get() = MstSymbolDelegateProvider
public val Algebra<MST>.symbol: PropertyDelegateProvider<Algebra<MST>, ReadOnlyProperty<Algebra<MST>, MST.Symbolic>>
get() = PropertyDelegateProvider { _, _ -> ReadOnlyProperty { _, p -> MST.Symbolic(p.name) } }