net.openhft.chronicle.core.ClassLocal Maven / Gradle / Ivy
/*
* Copyright 2016 higherfrequencytrading.com
*
* 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 net.openhft.chronicle.core;
import org.jetbrains.annotations.NotNull;
import java.util.function.Function;
/**
* Lambda friendly, ClassLocal value to cache information relating to a class.
*
* @param the type of value in this ClassLocal
*/
public class ClassLocal extends ClassValue {
private final Function, V> classVFunction;
private ClassLocal(Function, V> classVFunction) {
this.classVFunction = classVFunction;
}
/**
* Function to create a value to cache information associated with a Class
*
* @param classVFunction to generate the associated value.
* @param the type of value in this ClassLocal
* @return the ClassLocal
*/
@NotNull
public static ClassLocal withInitial(Function, V> classVFunction) {
return new ClassLocal<>(classVFunction);
}
/**
* WARNING Do not call this directly
*/
@Override
@Deprecated
protected V computeValue(Class> type) {
return classVFunction.apply(type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy