All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.muserver.rest.ReadOnlyMultivaluedMap Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package io.muserver.rest;

import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

class ReadOnlyMultivaluedMap implements MultivaluedMap, Serializable {
    private static final MultivaluedMap EMPTY = readOnly(new MultivaluedHashMap<>());
    private final MultivaluedMap actual;

    private ReadOnlyMultivaluedMap(MultivaluedMap actual) {
        this.actual = actual;
    }

    static  MultivaluedMap readOnly(MultivaluedMap map) {
        return new ReadOnlyMultivaluedMap<>(map);
    }

    @SuppressWarnings("unchecked")
    static  MultivaluedMap empty() {
        return EMPTY;
    }


    public void putSingle(K key, V value) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public void add(K key, V value) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    @SafeVarargs
    public final void addAll(K key, V... newValues) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public void addAll(K key, List valueList) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public V getFirst(K key) {
        return actual.getFirst(key);
    }

    public void addFirst(K key, V value) {
        actual.addFirst(key, value);
    }

    public String toString() {
        return "Read Only: " + actual.toString();
    }

    public int hashCode() {
        return actual.hashCode();
    }

    public boolean equals(Object o) {
        return actual.equals(o);
    }

    public Collection> values() {
        return actual.values();
    }

    public int size() {
        return actual.size();
    }

    public List remove(Object key) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public void putAll(Map> m) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public List put(K key, List value) {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public Set keySet() {
        return actual.keySet();
    }

    public boolean isEmpty() {
        return actual.isEmpty();
    }

    public List get(Object key) {
        return actual.get(key);
    }

    public Set>> entrySet() {
        return actual.entrySet();
    }

    public boolean containsValue(Object value) {
        return actual.containsValue(value);
    }

    public boolean containsKey(Object key) {
        return actual.containsKey(key);
    }

    public void clear() {
        throw new NotImplementedException("Invalid access for readonly map");
    }

    public boolean equalsIgnoreValueOrder(MultivaluedMap omap) {
        return actual.equalsIgnoreValueOrder(omap);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy