/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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 io.vertx.reactivex.core.shareddata;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import java.util.Map;
Local maps can be used to share data safely in a single Vert.x instance.
By default the map allows immutable keys and values. Custom keys and values should implement Shareable
interface. The map returns their copies.
This ensures there is no shared access to mutable state from different threads (e.g. different event loops) in the
Vert.x instance, and means you don't have to protect access to that state using synchronization or locks.
Since the version 3.4, this class extends the interface. However some methods are only accessible in Java.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Local maps can be used to share data safely in a single Vert.x instance.
* <p>
* By default the map allows immutable keys and values.
* Custom keys and values should implement {@link io.vertx.core.shareddata.Shareable} interface. The map returns their copies.
* <p>
* This ensures there is no shared access to mutable state from different threads (e.g. different event loops) in the
* Vert.x instance, and means you don't have to protect access to that state using synchronization or locks.
* <p>
*
* Since the version 3.4, this class extends the interface. However some methods are only accessible in Java.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.core.shareddata.LocalMap original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rx.RxGen(io.vertx.core.shareddata.LocalMap.class)
public class LocalMap<K,V> {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LocalMap that = (LocalMap) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<LocalMap> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new LocalMap((io.vertx.core.shareddata.LocalMap) obj),
LocalMap::getDelegate
);
private final io.vertx.core.shareddata.LocalMap<K,V> delegate;
public final io.vertx.lang.rx.TypeArg<K> __typeArg_0;
public final io.vertx.lang.rx.TypeArg<V> __typeArg_1;
public LocalMap(io.vertx.core.shareddata.LocalMap delegate) {
this.delegate = delegate;
this.__typeArg_0 = io.vertx.lang.rx.TypeArg.unknown(); this.__typeArg_1 = io.vertx.lang.rx.TypeArg.unknown(); }
public LocalMap(io.vertx.core.shareddata.LocalMap delegate, io.vertx.lang.rx.TypeArg<K> typeArg_0, io.vertx.lang.rx.TypeArg<V> typeArg_1) {
this.delegate = delegate;
this.__typeArg_0 = typeArg_0;
this.__typeArg_1 = typeArg_1;
}
public io.vertx.core.shareddata.LocalMap getDelegate() {
return delegate;
}
Get a value from the map
Params: - key – the key
Returns: the value, or null if none
/**
* Get a value from the map
* @param key the key
* @return the value, or null if none
*/
public V get(Object key) {
V ret = (V)__typeArg_1.wrap(delegate.get(key));
return ret;
}
Put an entry in the map
Params: - key – the key
- value – the value
Returns: return the old value, or null if none
/**
* Put an entry in the map
* @param key the key
* @param value the value
* @return return the old value, or null if none
*/
public V put(K key, V value) {
V ret = (V)__typeArg_1.wrap(delegate.put(__typeArg_0.<K>unwrap(key), __typeArg_1.<V>unwrap(value)));
return ret;
}
Remove an entry from the map
Params: - key – the key
Returns: the old value
/**
* Remove an entry from the map
* @param key the key
* @return the old value
*/
public V remove(Object key) {
V ret = (V)__typeArg_1.wrap(delegate.remove(key));
return ret;
}
Clear all entries in the map
/**
* Clear all entries in the map
*/
public void clear() {
delegate.clear();
}
Get the size of the map
Returns: the number of entries in the map
/**
* Get the size of the map
* @return the number of entries in the map
*/
public int size() {
int ret = delegate.size();
return ret;
}
Returns: true if there are zero entries in the map
/**
* @return true if there are zero entries in the map
*/
public boolean isEmpty() {
boolean ret = delegate.isEmpty();
return ret;
}
Put the entry only if there is no existing entry for that key
Params: - key – the key
- value – the value
Returns: the old value or null, if none
/**
* Put the entry only if there is no existing entry for that key
* @param key the key
* @param value the value
* @return the old value or null, if none
*/
public V putIfAbsent(K key, V value) {
V ret = (V)__typeArg_1.wrap(delegate.putIfAbsent(__typeArg_0.<K>unwrap(key), __typeArg_1.<V>unwrap(value)));
return ret;
}
Remove the entry only if there is an entry with the specified key and value.
This method is the poyglot version of remove
.
Params: - key – the key
- value – the value
Returns: true if removed
/**
* Remove the entry only if there is an entry with the specified key and value.
* <p>
* This method is the poyglot version of {@link io.vertx.reactivex.core.shareddata.LocalMap#remove}.
* @param key the key
* @param value the value
* @return true if removed
*/
public boolean removeIfPresent(K key, V value) {
boolean ret = delegate.removeIfPresent(__typeArg_0.<K>unwrap(key), __typeArg_1.<V>unwrap(value));
return ret;
}
Replace the entry only if there is an existing entry with the specified key and value.
This method is the polyglot version of replace
.
Params: - key – the key
- oldValue – the old value
- newValue – the new value
Returns: true if removed
/**
* Replace the entry only if there is an existing entry with the specified key and value.
* <p>
* This method is the polyglot version of {@link io.vertx.reactivex.core.shareddata.LocalMap#replace}.
* @param key the key
* @param oldValue the old value
* @param newValue the new value
* @return true if removed
*/
public boolean replaceIfPresent(K key, V oldValue, V newValue) {
boolean ret = delegate.replaceIfPresent(__typeArg_0.<K>unwrap(key), __typeArg_1.<V>unwrap(oldValue), __typeArg_1.<V>unwrap(newValue));
return ret;
}
Replace the entry only if there is an existing entry with the key
Params: - key – the key
- value – the new value
Returns: the old value
/**
* Replace the entry only if there is an existing entry with the key
* @param key the key
* @param value the new value
* @return the old value
*/
public V replace(K key, V value) {
V ret = (V)__typeArg_1.wrap(delegate.replace(__typeArg_0.<K>unwrap(key), __typeArg_1.<V>unwrap(value)));
return ret;
}
Close and release the map
/**
* Close and release the map
*/
public void close() {
delegate.close();
}
Returns true
if this map contains a mapping for the specified
key.
Params: - key – key whose presence in this map is to be tested
Returns: true
if this map contains a mapping for the specified key
/**
* Returns <code>true</code> if this map contains a mapping for the specified
* key.
* @param key key whose presence in this map is to be tested
* @return <code>true</code> if this map contains a mapping for the specified key
*/
public boolean containsKey(Object key) {
boolean ret = delegate.containsKey(key);
return ret;
}
Returns @{code true} if this map maps one or more keys to the
specified value.
Params: - value – value whose presence in this map is to be tested
Returns: @{code true} if this map maps one or more keys to the specified value
/**
* Returns @{code true} if this map maps one or more keys to the
* specified value.
* @param value value whose presence in this map is to be tested
* @return @{code true} if this map maps one or more keys to the specified value
*/
public boolean containsValue(Object value) {
boolean ret = delegate.containsValue(value);
return ret;
}
Returns the value to which the specified key is mapped, or
defaultValue
if this map contains no mapping for the key.
Params: - key – the key whose associated value is to be returned
- defaultValue – the default mapping of the key
Returns: the value to which the specified key is mapped, or defaultValue
if this map contains no mapping for the key
/**
* Returns the value to which the specified key is mapped, or
* <code>defaultValue</code> if this map contains no mapping for the key.
* @param key the key whose associated value is to be returned
* @param defaultValue the default mapping of the key
* @return the value to which the specified key is mapped, or <code>defaultValue</code> if this map contains no mapping for the key
*/
public V getOrDefault(Object key, V defaultValue) {
V ret = (V)__typeArg_1.wrap(delegate.getOrDefault(key, __typeArg_1.<V>unwrap(defaultValue)));
return ret;
}
public static <K,V>LocalMap<K,V> newInstance(io.vertx.core.shareddata.LocalMap arg) {
return arg != null ? new LocalMap<K,V>(arg) : null;
}
public static <K,V>LocalMap<K,V> newInstance(io.vertx.core.shareddata.LocalMap arg, io.vertx.lang.rx.TypeArg<K> __typeArg_K, io.vertx.lang.rx.TypeArg<V> __typeArg_V) {
return arg != null ? new LocalMap<K,V>(arg, __typeArg_K, __typeArg_V) : null;
}
}