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) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.util;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.io.Serializable;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
/**
* Implementation of the {@link Map} interface which stores a single mapping. The key set is shared among all instances
* which contain the same key. This implementation does not support null keys or values.
*
*
* In case the set of keys is statically known, you can use {@link SharedSingletonMapTemplate} to efficiently create
* {@link SharedSingletonMap} instances.
*
* @param the type of keys maintained by this map
* @param the type of mapped values
*/
@Beta
public abstract class SharedSingletonMap implements Serializable, UnmodifiableMapPhase {
static final class Ordered extends SharedSingletonMap {
private static final long serialVersionUID = 1L;
Ordered(final K key, final V value) {
super(key, value);
}
Ordered(final SingletonSet keySet, final V value) {
super(keySet, value);
}
@Override
public @NonNull ModifiableMapPhase toModifiableMap() {
return MutableOffsetMap.orderedCopyOf(this);
}
}
static final class Unordered extends SharedSingletonMap {
private static final long serialVersionUID = 1L;
Unordered(final K key, final V value) {
super(key, value);
}
Unordered(final SingletonSet keySet, final V value) {
super(keySet, value);
}
@Override
public @NonNull ModifiableMapPhase toModifiableMap() {
return MutableOffsetMap.unorderedCopyOf(this);
}
}
private static final long serialVersionUID = 1L;
private static final LoadingCache