/*
* Copyright (C) 2012, 2016 higherfrequencytrading.com
* Copyright (C) 2016 Roman Leventov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.Data;
import org.jetbrains.annotations.NotNull;
/**
* Default value computation strategy, used
* in {@link ChronicleMapBuilder#defaultValueProvider(DefaultValueProvider)} configuration.
*
* @param <K> map key class
* @param <V> map value class
*/
@FunctionalInterface
public interface DefaultValueProvider<K, V> {
/**
* Returns the "nil" value, which should be inserted into the map, in the given
* {@code absentEntry} context. This is primarily used in {@link ChronicleMap#acquireUsing}
* operation implementation, i. e. {@link MapMethods#acquireUsing}.
*
* The default implementation simply delegates to {@link MapAbsentEntry#defaultValue()}.
*/
Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry);
}