1. /*
  2. * Copyright 2003-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.collections.bidimap;
  17. import org.apache.commons.collections.BidiMap;
  18. import org.apache.commons.collections.MapIterator;
  19. import org.apache.commons.collections.map.AbstractMapDecorator;
  20. /**
  21. * Provides a base decorator that enables additional functionality to be added
  22. * to a BidiMap via decoration.
  23. * <p>
  24. * Methods are forwarded directly to the decorated map.
  25. * <p>
  26. * This implementation does not perform any special processing with the map views.
  27. * Instead it simply returns the set/collection from the wrapped map. This may be
  28. * undesirable, for example if you are trying to write a validating implementation
  29. * it would provide a loophole around the validation.
  30. * But, you might want that loophole, so this class is kept simple.
  31. *
  32. * @since Commons Collections 3.0
  33. * @version $Revision: 1.5 $ $Date: 2004/02/18 00:57:39 $
  34. *
  35. * @author Stephen Colebourne
  36. */
  37. public abstract class AbstractBidiMapDecorator
  38. extends AbstractMapDecorator implements BidiMap {
  39. /**
  40. * Constructor that wraps (not copies).
  41. *
  42. * @param map the map to decorate, must not be null
  43. * @throws IllegalArgumentException if the collection is null
  44. */
  45. protected AbstractBidiMapDecorator(BidiMap map) {
  46. super(map);
  47. }
  48. /**
  49. * Gets the map being decorated.
  50. *
  51. * @return the decorated map
  52. */
  53. protected BidiMap getBidiMap() {
  54. return (BidiMap) map;
  55. }
  56. //-----------------------------------------------------------------------
  57. public MapIterator mapIterator() {
  58. return getBidiMap().mapIterator();
  59. }
  60. public Object getKey(Object value) {
  61. return getBidiMap().getKey(value);
  62. }
  63. public Object removeValue(Object value) {
  64. return getBidiMap().removeValue(value);
  65. }
  66. public BidiMap inverseBidiMap() {
  67. return getBidiMap().inverseBidiMap();
  68. }
  69. }