Coverage Summary for Class: AbstractMapEntry (com.google.common.collect)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| AbstractMapEntry | 100% (1/1) | 60% (3/5) | 63.6% (7/11) |
1 /* 2 * Copyright (C) 2007 The Guava Authors 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 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 import com.google.common.base.Objects; 21 import java.util.Map.Entry; 22 import org.checkerframework.checker.nullness.qual.Nullable; 23 24 /** 25 * Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@code 26 * Entry}. 27 * 28 * @author Jared Levy 29 */ 30 @GwtCompatible 31 abstract class AbstractMapEntry<K, V> implements Entry<K, V> { 32 33 @Override 34 public abstract K getKey(); 35 36 @Override 37 public abstract V getValue(); 38 39 @Override 40 public V setValue(V value) { 41 throw new UnsupportedOperationException(); 42 } 43 44 @Override 45 public boolean equals(@Nullable Object object) { 46 if (object instanceof Entry) { 47 Entry<?, ?> that = (Entry<?, ?>) object; 48 return Objects.equal(this.getKey(), that.getKey()) 49 && Objects.equal(this.getValue(), that.getValue()); 50 } 51 return false; 52 } 53 54 @Override 55 public int hashCode() { 56 K k = getKey(); 57 V v = getValue(); 58 return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode()); 59 } 60 61 /** Returns a string representation of the form {@code {key}={value}}. */ 62 @Override 63 public String toString() { 64 return getKey() + "=" + getValue(); 65 } 66 }