org.jetbrains.kotlin.storage.ObservableStorageManager.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.storage
import java.util.concurrent.ConcurrentMap
public abstract class ObservableStorageManager(private val delegate: StorageManager) : StorageManager {
protected abstract val (() -> T).observable: () -> T
protected abstract val ((K) -> V).observable: (K) -> V
override fun createMemoizedFunction(compute: (K) -> V): MemoizedFunctionToNotNull {
return delegate.createMemoizedFunction(compute.observable)
}
override fun createMemoizedFunctionWithNullableValues(compute: (K) -> V?): MemoizedFunctionToNullable {
return delegate.createMemoizedFunctionWithNullableValues(compute.observable)
}
override fun createMemoizedFunction(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNotNull {
return delegate.createMemoizedFunction(compute.observable, map)
}
override fun createMemoizedFunctionWithNullableValues(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNullable {
return delegate.createMemoizedFunctionWithNullableValues(compute.observable, map)
}
override fun createLazyValue(computable: () -> T): NotNullLazyValue {
return delegate.createLazyValue(computable.observable)
}
override fun createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue {
return delegate.createRecursionTolerantLazyValue(computable.observable, onRecursiveCall)
}
override fun createLazyValueWithPostCompute(computable: () -> T, onRecursiveCall: ((Boolean) -> T)?, postCompute: (T) -> Unit): NotNullLazyValue {
return delegate.createLazyValueWithPostCompute(computable.observable, onRecursiveCall, postCompute)
}
override fun createNullableLazyValue(computable: () -> T?): NullableLazyValue {
return delegate.createNullableLazyValue(computable.observable)
}
override fun createRecursionTolerantNullableLazyValue(computable: () -> T?, onRecursiveCall: T?): NullableLazyValue {
return delegate.createRecursionTolerantNullableLazyValue(computable.observable, onRecursiveCall)
}
override fun createNullableLazyValueWithPostCompute(computable: () -> T?, postCompute: (T?) -> Unit): NullableLazyValue {
return delegate.createNullableLazyValueWithPostCompute(computable.observable, postCompute)
}
override fun compute(computable: () -> T): T {
return delegate.compute(computable.observable)
}
}