1. /*
  2. * Copyright 2001-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.keyvalue;
  17. import java.util.Map;
  18. import org.apache.commons.collections.KeyValue;
  19. /**
  20. * A restricted implementation of {@link java.util.Map.Entry} that prevents
  21. * the MapEntry contract from being broken.
  22. *
  23. * @since Commons Collections 3.0
  24. * @version $Revision: 1.3 $ $Date: 2004/02/18 01:00:08 $
  25. *
  26. * @author James Strachan
  27. * @author Michael A. Smith
  28. * @author Neil O'Toole
  29. * @author Stephen Colebourne
  30. */
  31. public final class DefaultMapEntry extends AbstractMapEntry {
  32. /**
  33. * Constructs a new entry with the specified key and given value.
  34. *
  35. * @param key the key for the entry, may be null
  36. * @param value the value for the entry, may be null
  37. */
  38. public DefaultMapEntry(final Object key, final Object value) {
  39. super(key, value);
  40. }
  41. /**
  42. * Constructs a new entry from the specified KeyValue.
  43. *
  44. * @param pair the pair to copy, must not be null
  45. * @throws NullPointerException if the entry is null
  46. */
  47. public DefaultMapEntry(final KeyValue pair) {
  48. super(pair.getKey(), pair.getValue());
  49. }
  50. /**
  51. * Constructs a new entry from the specified MapEntry.
  52. *
  53. * @param entry the entry to copy, must not be null
  54. * @throws NullPointerException if the entry is null
  55. */
  56. public DefaultMapEntry(final Map.Entry entry) {
  57. super(entry.getKey(), entry.getValue());
  58. }
  59. }