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.OrderedBidiMap;
  18. import org.apache.commons.collections.OrderedMapIterator;
  19. /**
  20. * Provides a base decorator that enables additional functionality to be added
  21. * to an OrderedBidiMap via decoration.
  22. * <p>
  23. * Methods are forwarded directly to the decorated map.
  24. * <p>
  25. * This implementation does not perform any special processing with the map views.
  26. * Instead it simply returns the inverse from the wrapped map. This may be
  27. * undesirable, for example if you are trying to write a validating implementation
  28. * it would provide a loophole around the validation.
  29. * But, you might want that loophole, so this class is kept simple.
  30. *
  31. * @since Commons Collections 3.0
  32. * @version $Revision: 1.4 $ $Date: 2004/02/18 00:57:39 $
  33. *
  34. * @author Stephen Colebourne
  35. */
  36. public abstract class AbstractOrderedBidiMapDecorator
  37. extends AbstractBidiMapDecorator implements OrderedBidiMap {
  38. /**
  39. * Constructor that wraps (not copies).
  40. *
  41. * @param map the map to decorate, must not be null
  42. * @throws IllegalArgumentException if the collection is null
  43. */
  44. protected AbstractOrderedBidiMapDecorator(OrderedBidiMap map) {
  45. super(map);
  46. }
  47. /**
  48. * Gets the map being decorated.
  49. *
  50. * @return the decorated map
  51. */
  52. protected OrderedBidiMap getOrderedBidiMap() {
  53. return (OrderedBidiMap) map;
  54. }
  55. //-----------------------------------------------------------------------
  56. public OrderedMapIterator orderedMapIterator() {
  57. return getOrderedBidiMap().orderedMapIterator();
  58. }
  59. public Object firstKey() {
  60. return getOrderedBidiMap().firstKey();
  61. }
  62. public Object lastKey() {
  63. return getOrderedBidiMap().lastKey();
  64. }
  65. public Object nextKey(Object key) {
  66. return getOrderedBidiMap().nextKey(key);
  67. }
  68. public Object previousKey(Object key) {
  69. return getOrderedBidiMap().previousKey(key);
  70. }
  71. public OrderedBidiMap inverseOrderedBidiMap() {
  72. return getOrderedBidiMap().inverseOrderedBidiMap();
  73. }
  74. }