package org.eclipse.collections.impl;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
public class UnmodifiableMap<K, V> implements Map<K, V>, Serializable
{
private static final long serialVersionUID = 1L;
protected final Map<K, V> delegate;
public UnmodifiableMap(Map<K, V> delegate)
{
if (delegate == null)
{
throw new NullPointerException();
}
this.delegate = delegate;
}
@Override
public int size()
{
return this.delegate.size();
}
@Override
public boolean isEmpty()
{
return this.delegate.isEmpty();
}
@Override
public boolean containsKey(Object key)
{
return this.delegate.containsKey(key);
}
@Override
public boolean containsValue(Object value)
{
return this.delegate.containsValue(value);
}
@Override
public V get(Object key)
{
return this.delegate.get(key);
}
@Override
public V put(K key, V value)
{
throw new UnsupportedOperationException("Cannot call put() on " + this.getClass().getSimpleName());
}
@Override
public V remove(Object key)
{
throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
}
@Override
public void putAll(Map<? extends K, ? extends V> t)
{
throw new UnsupportedOperationException("Cannot call putAll() on " + this.getClass().getSimpleName());
}
@Override
public void clear()
{
throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName());
}
@Override
public Set<K> keySet()
{
return Collections.unmodifiableSet(this.delegate.keySet());
}
@Override
public Set<Map.Entry<K, V>> entrySet()
{
return Collections.unmodifiableMap(this.delegate).entrySet();
}
@Override
public Collection<V> values()
{
return Collections.unmodifiableCollection(this.delegate.values());
}
@Override
public boolean equals(Object o)
{
return o == this || this.delegate.equals(o);
}
@Override
public int hashCode()
{
return this.delegate.hashCode();
}
@Override
public String toString()
{
return this.delegate.toString();
}
}