Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2016 Goldman Sachs.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/package org.eclipse.collections.impl.map.mutable;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.primitive.MutableBooleanBag;
import org.eclipse.collections.api.bag.primitive.MutableByteBag;
import org.eclipse.collections.api.bag.primitive.MutableCharBag;
import org.eclipse.collections.api.bag.primitive.MutableDoubleBag;
import org.eclipse.collections.api.bag.primitive.MutableFloatBag;
import org.eclipse.collections.api.bag.primitive.MutableIntBag;
import org.eclipse.collections.api.bag.primitive.MutableLongBag;
import org.eclipse.collections.api.bag.primitive.MutableShortBag;
import org.eclipse.collections.api.bag.sorted.MutableSortedBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.BooleanFunction;
import org.eclipse.collections.api.block.function.primitive.ByteFunction;
import org.eclipse.collections.api.block.function.primitive.CharFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleObjectToDoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.FloatObjectToFloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.LongObjectToLongFunction;
import org.eclipse.collections.api.block.function.primitive.ShortFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.collection.primitive.MutableBooleanCollection;
import org.eclipse.collections.api.collection.primitive.MutableByteCollection;
import org.eclipse.collections.api.collection.primitive.MutableCharCollection;
import org.eclipse.collections.api.collection.primitive.MutableDoubleCollection;
import org.eclipse.collections.api.collection.primitive.MutableFloatCollection;
import org.eclipse.collections.api.collection.primitive.MutableIntCollection;
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.ImmutableMap;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap;
import org.eclipse.collections.api.map.primitive.MutableObjectLongMap;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.multimap.MutableMultimap;
import org.eclipse.collections.api.multimap.bag.MutableBagMultimap;
import org.eclipse.collections.api.multimap.set.MutableSetMultimap;
import org.eclipse.collections.api.ordered.OrderedIterable;
import org.eclipse.collections.api.partition.bag.PartitionMutableBag;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.UnmodifiableIteratorAdapter;
import org.eclipse.collections.impl.UnmodifiableMap;
import org.eclipse.collections.impl.factory.Maps;
import org.eclipse.collections.impl.tuple.AbstractImmutableEntry;
import org.eclipse.collections.impl.utility.LazyIterate;
/**
* An unmodifiable view of a map.
*
* @see MutableMap#asUnmodifiable()
*/publicclassUnmodifiableMutableMapextendsUnmodifiableMapimplementsMutableMap{
privatestaticfinallong serialVersionUID = 1L;
protectedUnmodifiableMutableMap(MutableMap map){
super(map);
}
/**
* This method will take a MutableMap and wrap it directly in a UnmodifiableMutableMap. It will
* take any other non-GS-map and first adapt it will a MapAdapter, and then return a
* UnmodifiableMutableMap that wraps the adapter.
*/publicstatic> UnmodifiableMutableMapof(M map){
if (map == null)
{
thrownew IllegalArgumentException("cannot create a UnmodifiableMutableMap for null");
}
returnnew UnmodifiableMutableMap<>(MapAdapter.adapt(map));
}
@Overridepublic MutableMapnewEmpty(){
returnthis.getMutableMap().newEmpty();
}
@OverridepublicbooleannotEmpty(){
returnthis.getMutableMap().notEmpty();
}
@OverridepublicvoidforEachValue(Procedure procedure){
this.getMutableMap().forEachValue(procedure);
}
@OverridepublicvoidforEachKey(Procedure procedure){
this.getMutableMap().forEachKey(procedure);
}
@OverridepublicvoidforEachKeyValue(Procedure2 procedure){
this.getMutableMap().forEachKeyValue(procedure);
}
@Overridepublic MutableMapflipUniqueValues(){
returnthis.getMutableMap().flipUniqueValues();
}
@Overridepublic MutableMapcollectKeysAndValues(
Iterable iterable,
Function keyFunction,
Function valueFunction){
thrownew UnsupportedOperationException("Cannot call collectKeysAndValues() on " + this.getClass().getSimpleName());
}
@Overridepublic V removeKey(K key){
thrownew UnsupportedOperationException("Cannot call removeKey() on " + this.getClass().getSimpleName());
}
@Overridepublic V updateValue(K key, Function0 factory, Function function){
thrownew UnsupportedOperationException("Cannot call updateValue() on " + this.getClass().getSimpleName());
}
@Overridepublic
V updateValueWith(
K key,
Function0 factory,
Function2 function,
P parameter){
thrownew UnsupportedOperationException("Cannot call updateValueWith() on " + this.getClass().getSimpleName());
}
@Overridepublic V getIfAbsentPut(K key, Function0 function){
V result = this.get(key);
if (this.isAbsent(result, key))
{
thrownew UnsupportedOperationException("Cannot mutate " + this.getClass().getSimpleName());
}
return result;
}
@Overridepublic V getIfAbsentPut(K key, V value){
V result = this.get(key);
if (this.isAbsent(result, key))
{
thrownew UnsupportedOperationException("Cannot mutate " + this.getClass().getSimpleName());
}
return result;
}
@Overridepublic V getIfAbsentPutWithKey(K key, Function function){
returnthis.getIfAbsentPutWith(key, function, key);
}
@Overridepublic
V getIfAbsentPutWith(
K key,
Function function,
P parameter){
V result = this.get(key);
if (this.isAbsent(result, key))
{
thrownew UnsupportedOperationException("Cannot mutate " + this.getClass().getSimpleName());
}
return result;
}
@Overridepublic V getIfAbsent(K key, Function0 function){
V result = this.get(key);
if (this.isAbsent(result, key))
{
return function.value();
}
return result;
}
@Overridepublic V getIfAbsentValue(K key, V value){
V result = this.get(key);
if (this.isAbsent(result, key))
{
return value;
}
return result;
}
@Overridepublic