mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Improved documentation
This commit is contained in:
@@ -28,7 +28,9 @@ import java.io.Serializable;
|
||||
*
|
||||
* @param <K> map key class
|
||||
* @param <V> map value class
|
||||
* @deprecated specialize {@link MapEntryOperations#defaultValue(MapAbsentEntry)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface DefaultValueProvider<K, V> extends Serializable {
|
||||
/**
|
||||
* Returns a value to be put during {@link ChronicleMap#acquireUsing(Object, Object)} call
|
||||
|
||||
@@ -20,6 +20,17 @@ package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.ExternalHashQueryContext;
|
||||
|
||||
/**
|
||||
* {@link MapQueryContext} + {@link AutoCloseable}, for external {@link ChronicleMap} queries
|
||||
* in <i>try-with-resources</i> blocks.
|
||||
*
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @param <R> the return type of {@link MapEntryOperations}, {@link
|
||||
* ChronicleMapBuilder#entryOperations(MapEntryOperations) specified} for the queried {@code
|
||||
* ChronicleMap}
|
||||
* @see ChronicleMap#queryContext(Object)
|
||||
*/
|
||||
public interface ExternalMapQueryContext<K, V, R>
|
||||
extends MapQueryContext<K, V, R>, ExternalHashQueryContext<K> {
|
||||
}
|
||||
|
||||
@@ -38,20 +38,29 @@ public interface MapAbsentEntry<K, V> extends HashAbsentEntry<K> {
|
||||
@NotNull MapContext<K, V, ?> context();
|
||||
|
||||
/**
|
||||
* Inserts the new entry into the map, of {@link #absentKey() the key} and the given value.
|
||||
* Inserts the new entry into the map, of {@linkplain #absentKey() the key} and the given {@code
|
||||
* value}.
|
||||
*
|
||||
* <p>This method is the default implementation for {@link MapEntryOperations#insert(
|
||||
* MapAbsentEntry, Value)}, which might be customized over the default.
|
||||
*
|
||||
* @param value the value to insert into the map along with {@link #absentKey() the key}
|
||||
* @throws IllegalStateException if some locking/state conditions required to perform insertion
|
||||
* operation are not met
|
||||
* @see MapEntryOperations#insert(MapAbsentEntry, Value)
|
||||
*/
|
||||
void doInsert(Value<V, ?> value);
|
||||
|
||||
/**
|
||||
* Returns the "nil" value, which should be inserted into the map in this context. This
|
||||
* is primarily used in {@link ChronicleMap#acquireUsing} operation implementation, i. e. {@link
|
||||
* MapMethods#acquireUsing}.
|
||||
* Returns the <i>default</i> (or <i>nil</i>) value, that should be inserted into the map in
|
||||
* this context. This is primarily used in {@link ChronicleMap#acquireUsing} operation
|
||||
* implementation, i. e. {@link MapMethods#acquireUsing}.
|
||||
*
|
||||
* <p>This method if the default implementation for {@link
|
||||
* MapEntryOperations#defaultValue}, which might be customized over the default.
|
||||
*
|
||||
* @return the default value to be inserted into the map
|
||||
* @see MapEntryOperations#defaultValue(MapAbsentEntry)
|
||||
*/
|
||||
@NotNull Value<V, ?> defaultValue();
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import net.openhft.chronicle.hash.Value;
|
||||
/**
|
||||
* Context, in which {@link MapEntry MapEntries} are accessed.
|
||||
*
|
||||
* @param <K> the key type of accessed {@link ChronicleMap}
|
||||
* @param <V> the value type of accessed {@code ChronicleMap}
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @param <R> the return type of {@link MapEntryOperations} specialized for the queried map
|
||||
*/
|
||||
public interface MapContext<K, V, R> extends HashContext<K>, MapEntryOperations<K, V, R> {
|
||||
/**
|
||||
* Returns the accessed {@code ChronicleMap}.
|
||||
* Returns the accessed {@code ChronicleMap}. Synonym to {@link #map()}.
|
||||
*/
|
||||
@Override
|
||||
default ChronicleMap<K, V> hash() {
|
||||
@@ -37,9 +38,19 @@ public interface MapContext<K, V, R> extends HashContext<K>, MapEntryOperations<
|
||||
}
|
||||
|
||||
/**
|
||||
* Synonym to {@link #hash()}.
|
||||
* Returns the accessed {@code ChronicleMap}. Synonym to {@link #hash()}.
|
||||
*/
|
||||
ChronicleMap<K, V> map();
|
||||
|
||||
|
||||
/**
|
||||
* Wraps the given value as a {@code Value}. Useful when you need to pass a value
|
||||
* to some method accepting {@code Value}, for example, {@link MapEntryOperations#replaceValue(
|
||||
* MapEntry, Value)}, without allocating new objects (i. e. garbage) and {@code ThreadLocals}.
|
||||
*
|
||||
* <p>The returned {@code Value} object shouldn't outlive this {@code MapContext}.
|
||||
*
|
||||
* @param value the value object to wrap
|
||||
* @return the value as {@code Value}
|
||||
*/
|
||||
Value<V, ?> wrapValueAsValue(V value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2015 Higher Frequency Trading
|
||||
*
|
||||
@@ -25,12 +23,12 @@ import net.openhft.chronicle.hash.Value;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Access to the <i>present</i> {@link ChronicleMap} entry.
|
||||
* The <i>present</i> {@code ChronicleHash} entry context.
|
||||
*
|
||||
* @param <K> type of the key in {@code ChronicleMap}
|
||||
* @param <V> type of the value in {@code ChronicleMap}
|
||||
*
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @see MapEntryOperations
|
||||
* @see MapQueryContext#entry()
|
||||
*/
|
||||
public interface MapEntry<K, V> extends HashEntry<K> {
|
||||
@Override
|
||||
@@ -42,10 +40,24 @@ public interface MapEntry<K, V> extends HashEntry<K> {
|
||||
@NotNull Value<V, ?> value();
|
||||
|
||||
/**
|
||||
* Replaces the entry's value with the new one.
|
||||
* Replaces the entry's value with the given {@code newValue}.
|
||||
*
|
||||
* <p>This method is the default implementation for {@link MapEntryOperations#replaceValue(
|
||||
* MapEntry, Value)}, which might be customized over the default.
|
||||
*
|
||||
* @param newValue the value to be put into the map instead of the {@linkplain #value() current
|
||||
* value}
|
||||
* @throws IllegalStateException if some locking/state conditions required to perform replace
|
||||
* operation are not met
|
||||
*/
|
||||
void doReplaceValue(Value<V, ?> newValue);
|
||||
|
||||
/**
|
||||
* Removes the entry from the map.
|
||||
*
|
||||
* <p>This method is the default implementation for {@link MapEntryOperations#remove(MapEntry)},
|
||||
* which might be customized over the default.
|
||||
*/
|
||||
@Override
|
||||
void doRemove();
|
||||
}
|
||||
|
||||
@@ -22,16 +22,20 @@ import net.openhft.chronicle.hash.Value;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* SPI interface for customizing "low-level" modification operations on {@link ChronicleMap} entry.
|
||||
* SPI interface for customizing "low-level" modification operations on {@link ChronicleMap}
|
||||
* entries.
|
||||
*
|
||||
* @param <K> type of the key in {@code ChronicleMap}
|
||||
* @param <V> type of the value in {@code ChronicleMap}
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @see ChronicleMapBuilder#entryOperations(MapEntryOperations)
|
||||
*/
|
||||
public interface MapEntryOperations<K, V, R> {
|
||||
|
||||
/**
|
||||
* Removes the given entry from the {@code ChronicleHash}. Returns {@code true} if the remove
|
||||
* was successful, {@code false} if it was discarded for any reason.
|
||||
* Removes the given entry from the map.
|
||||
*
|
||||
* @implNote default implementation calls {@link MapEntry#doRemove()} on the given entry
|
||||
* and returns {@code null}.
|
||||
*
|
||||
* @param entry the entry to remove
|
||||
* @throws IllegalStateException if some locking/state conditions required to perform remove
|
||||
|
||||
@@ -18,6 +18,11 @@ package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.KeyContext;
|
||||
|
||||
/**
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @deprecated incoherent abstraction. Replaced by {@link MapQueryContext} and {@link MapEntry}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MapKeyContext<K, V> extends KeyContext<K> {
|
||||
|
||||
|
||||
@@ -19,14 +19,18 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.HashQueryContext;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteOperations;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The context of Map operations with <i>individual keys</i> (most: get(), put(), etc., opposed
|
||||
* to bulk operations).
|
||||
*
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
* The context of {@link ChronicleMap} operations with <i>individual keys</i>
|
||||
* (most: {@code get()}, {@code put()}, etc., opposed to <i>bulk</i> operations). This is the main
|
||||
* context type of {@link MapMethods} and {@link MapRemoteOperations}.
|
||||
*
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @param <R> the return type of {@link MapEntryOperations} specialized for the queried map
|
||||
* @see ChronicleMap#queryContext(Object)
|
||||
*/
|
||||
public interface MapQueryContext<K, V, R> extends HashQueryContext<K>, MapContext<K, V, R> {
|
||||
|
||||
|
||||
@@ -20,9 +20,19 @@ package net.openhft.chronicle.map.replication;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.HashRemoteQueryContext;
|
||||
import net.openhft.chronicle.hash.replication.RemoteOperationContext;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.MapEntryOperations;
|
||||
import net.openhft.chronicle.map.MapQueryContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Context of remote {@link ChronicleMap} queries and internal replication operations.
|
||||
*
|
||||
* @param <K> the map key type
|
||||
* @param <V> the map value type
|
||||
* @param <R> the return type of {@link MapEntryOperations} specialized for the queried map
|
||||
* @see MapRemoteOperations
|
||||
*/
|
||||
public interface MapRemoteQueryContext<K, V, R> extends MapQueryContext<K, V, R>,
|
||||
HashRemoteQueryContext<K> {
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user