Files
Chronicle-Map/src/main/java/net/openhft/chronicle/map/DefaultValueProvider.java
T

43 lines
1.6 KiB
Java

/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* 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
* @see ChronicleMapBuilder#defaultValue(Object)
*/
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}.
*
* @implNote simply delegates to {@link MapAbsentEntry#defaultValue()}.
*/
default Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
return absentEntry.defaultValue();
}
}