io.vertx.rxjava.core.MultiMap Maven / Gradle / Ivy
/*
* 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.rxjava.core;
import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
/**
* This class represents a MultiMap of String keys to a List of String values.
*
* It's useful in Vert.x to represent things in Vert.x like HTTP headers and HTTP parameters which allow
* multiple values for keys.
*
*
* NOTE: This class has been automatically generated from the {@link io.vertx.core.MultiMap original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.core.MultiMap.class)
public class MultiMap implements Iterable> {
@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;
MultiMap that = (MultiMap) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public Iterator> iterator() {
return delegate.iterator();
}
public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new MultiMap((io.vertx.core.MultiMap) obj),
MultiMap::getDelegate
);
private final io.vertx.core.MultiMap delegate;
public MultiMap(io.vertx.core.MultiMap delegate) {
this.delegate = delegate;
}
public MultiMap(Object delegate) {
this.delegate = (io.vertx.core.MultiMap)delegate;
}
public io.vertx.core.MultiMap getDelegate() {
return delegate;
}
/**
* Create a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.
* @return the multi-map
*/
public static io.vertx.rxjava.core.MultiMap caseInsensitiveMultiMap() {
io.vertx.rxjava.core.MultiMap ret = io.vertx.rxjava.core.MultiMap.newInstance((io.vertx.core.MultiMap)io.vertx.core.MultiMap.caseInsensitiveMultiMap());
return ret;
}
/**
* Returns the value of with the specified name. If there are
* more than one values for the specified name, the first value is returned.
* @param name The name of the header to search
* @return The first header value or null
if there is no such entry
*/
public String get(String name) {
String ret = delegate.get(name);
return ret;
}
/**
* Returns the values with the specified name
* @param name The name to search
* @return A immutable {@link java.util.List} of values which will be empty if no values are found
*/
public List getAll(String name) {
List ret = delegate.getAll(name);
return ret;
}
/**
* Checks to see if there is a value with the specified name
* @param name The name to search for
* @return true if at least one entry is found
*/
public boolean contains(String name) {
boolean ret = delegate.contains(name);
return ret;
}
/**
* Check if there is a header with the specified name
and value
.
*
* If caseInsensitive
is true
, value
is compared in a case-insensitive way.
* @param name the name to search for
* @param value the value to search for
* @param caseInsensitive
* @return true
if at least one entry is found
*/
public boolean contains(String name, String value, boolean caseInsensitive) {
boolean ret = delegate.contains(name, value, caseInsensitive);
return ret;
}
/**
* Return true if empty
* @return
*/
public boolean isEmpty() {
boolean ret = delegate.isEmpty();
return ret;
}
/**
* Gets a immutable {@link java.util.Set} of all names
* @return A {@link java.util.Set} of all names
*/
public Set names() {
Set ret = delegate.names();
return ret;
}
/**
* Adds a new value with the specified name and value.
* @param name The name
* @param value The value being added
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap add(String name, String value) {
delegate.add(name, value);
return this;
}
/**
* Adds all the entries from another MultiMap to this one
* @param map
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap addAll(io.vertx.rxjava.core.MultiMap map) {
delegate.addAll(map.getDelegate());
return this;
}
/**
* Sets a value
under the specified name
.
*
* If there is an existing header with the same name, it is removed. Setting a null
value removes the entry.
* @param name The name
* @param value The value
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap set(String name, String value) {
delegate.set(name, value);
return this;
}
/**
* Cleans this instance.
* @param map
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap setAll(io.vertx.rxjava.core.MultiMap map) {
delegate.setAll(map.getDelegate());
return this;
}
/**
* Removes the value with the given name
* @param name The name of the value to remove
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap remove(String name) {
delegate.remove(name);
return this;
}
/**
* Removes all
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap clear() {
delegate.clear();
return this;
}
/**
* Return the number of keys.
* @return
*/
public int size() {
int ret = delegate.size();
return ret;
}
public String get(java.lang.CharSequence name) {
String ret = delegate.get(name);
return ret;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#getAll} but accepting a CharSequence
as a parameter
* @param name
* @return
*/
public List getAll(java.lang.CharSequence name) {
List ret = delegate.getAll(name);
return ret;
}
/**
* Returns all entries in the multi-map.
* @return A immutable {@link java.util.List} of the name-value entries, which will be empty if no pairs are found
*/
public List> entries() {
List> ret = delegate.entries();
return ret;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#contains} but accepting a CharSequence
as a parameter
* @param name
* @return
*/
public boolean contains(java.lang.CharSequence name) {
boolean ret = delegate.contains(name);
return ret;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#contains} but accepting CharSequence
parameters.
* @param name
* @param value
* @param caseInsensitive
* @return
*/
public boolean contains(java.lang.CharSequence name, java.lang.CharSequence value, boolean caseInsensitive) {
boolean ret = delegate.contains(name, value, caseInsensitive);
return ret;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#add} but accepting CharSequence
as parameters
* @param name
* @param value
* @return
*/
public io.vertx.rxjava.core.MultiMap add(java.lang.CharSequence name, java.lang.CharSequence value) {
delegate.add(name, value);
return this;
}
/**
* Adds a new values under the specified name
* @param name The name being set
* @param values The values
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap add(String name, java.lang.Iterable values) {
delegate.add(name, values);
return this;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#add} but accepting CharSequence
as parameters
* @param name
* @param values
* @return
*/
public io.vertx.rxjava.core.MultiMap add(java.lang.CharSequence name, java.lang.Iterable values) {
delegate.add(name, values);
return this;
}
/**
* Adds all the entries from a Map to this
* @param headers
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap addAll(java.util.Map headers) {
delegate.addAll(headers);
return this;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#set} but accepting CharSequence
as parameters
* @param name
* @param value
* @return
*/
public io.vertx.rxjava.core.MultiMap set(java.lang.CharSequence name, java.lang.CharSequence value) {
delegate.set(name, value);
return this;
}
/**
* Sets values for the specified name.
* @param name The name of the headers being set
* @param values The values of the headers being set
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap set(String name, java.lang.Iterable values) {
delegate.set(name, values);
return this;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#set} but accepting CharSequence
as parameters
* @param name
* @param values
* @return
*/
public io.vertx.rxjava.core.MultiMap set(java.lang.CharSequence name, java.lang.Iterable values) {
delegate.set(name, values);
return this;
}
/**
* Cleans and set all values of the given instance
* @param headers
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.core.MultiMap setAll(java.util.Map headers) {
delegate.setAll(headers);
return this;
}
/**
* Like {@link io.vertx.rxjava.core.MultiMap#remove} but accepting CharSequence
as parameters
* @param name
* @return
*/
public io.vertx.rxjava.core.MultiMap remove(java.lang.CharSequence name) {
delegate.remove(name);
return this;
}
public static MultiMap newInstance(io.vertx.core.MultiMap arg) {
return arg != null ? new MultiMap(arg) : null;
}
}