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

org.apache.commons.collections.bidimap.UnmodifiableOrderedBidiMap Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF 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 org.apache.commons.collections.bidimap;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.MapIterator;
import org.apache.commons.collections.OrderedBidiMap;
import org.apache.commons.collections.OrderedMapIterator;
import org.apache.commons.collections.Unmodifiable;
import org.apache.commons.collections.collection.UnmodifiableCollection;
import org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator;
import org.apache.commons.collections.map.UnmodifiableEntrySet;
import org.apache.commons.collections.set.UnmodifiableSet;

/**
 *  Decorates another OrderedBidiMap to ensure it can't be altered.
 *
 *  @since Commons Collections 3.0
 *  @version $Revision$ $Date$
 *
 *  @author Stephen Colebourne
 *
 * @deprecated Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
 */
@Deprecated(since = "2021-04-30")
public final class UnmodifiableOrderedBidiMap extends AbstractOrderedBidiMapDecorator implements Unmodifiable {

    /**
     * The inverse unmodifiable map
     */
    private UnmodifiableOrderedBidiMap inverse;

    /**
     * Factory method to create an unmodifiable map.
     * 

* If the map passed in is already unmodifiable, it is returned. * * @param map the map to decorate, must not be null * @return an unmodifiable OrderedBidiMap * @throws IllegalArgumentException if map is null */ public static OrderedBidiMap decorate(OrderedBidiMap map) { if (map instanceof Unmodifiable) { return map; } return new UnmodifiableOrderedBidiMap(map); } // ----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ private UnmodifiableOrderedBidiMap(OrderedBidiMap map) { super(map); } // ----------------------------------------------------------------------- public void clear() { throw new UnsupportedOperationException(); } public Object put(Object key, Object value) { throw new UnsupportedOperationException(); } public void putAll(Map mapToCopy) { throw new UnsupportedOperationException(); } public Object remove(Object key) { throw new UnsupportedOperationException(); } public Set entrySet() { Set set = super.entrySet(); return UnmodifiableEntrySet.decorate(set); } public Set keySet() { Set set = super.keySet(); return UnmodifiableSet.decorate(set); } public Collection values() { Collection coll = super.values(); return UnmodifiableCollection.decorate(coll); } // ----------------------------------------------------------------------- public Object removeValue(Object value) { throw new UnsupportedOperationException(); } public MapIterator mapIterator() { return orderedMapIterator(); } public BidiMap inverseBidiMap() { return inverseOrderedBidiMap(); } // ----------------------------------------------------------------------- public OrderedMapIterator orderedMapIterator() { OrderedMapIterator it = getOrderedBidiMap().orderedMapIterator(); return UnmodifiableOrderedMapIterator.decorate(it); } public OrderedBidiMap inverseOrderedBidiMap() { if (inverse == null) { inverse = new UnmodifiableOrderedBidiMap(getOrderedBidiMap().inverseOrderedBidiMap()); inverse.inverse = this; } return inverse; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy