Create an interface with provideDelegate() method #KT-26494

This commit is contained in:
Abduqodiri Qurbonzoda
2020-02-19 20:03:56 +03:00
parent 2566fbea87
commit afceec71a4
@@ -52,3 +52,27 @@ public interface ReadWriteProperty<in R, T> {
*/
public operator fun setValue(thisRef: R, property: KProperty<*>, value: T)
}
/**
* Base interface that can be used for implementing property delegate providers.
*
* This is provided only for convenience; you don't have to extend this interface
* as long as your delegate provider has a method with the same signature.
*
* @param T the type of object which owns the delegated property.
* @param D the type of property delegates this provider provides.
*/
@SinceKotlin("1.4")
public interface PropertyDelegateProvider<in T, out D> {
/**
* Returns the delegate of the property for the given object.
*
* This function can be used to extend the logic of creating the object (e.g. perform validation checks)
* to which the property implementation is delegated.
*
* @param thisRef the object for which property delegate is requested.
* @param property the metadata for the property.
* @return the property delegate.
*/
public operator fun provideDelegate(thisRef: T, property: KProperty<*>): D
}