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 java.io.Serializable; 21 import org.checkerframework.checker.nullness.qual.Nullable; 22 23 /** Simple base class to verify that we handle generics correctly. */ 24 @GwtCompatible 25 class Base implements Comparable<Base>, Serializable { 26 private final String s; 27 Base(String s)28 public Base(String s) { 29 this.s = s; 30 } 31 32 @Override hashCode()33 public int hashCode() { // delegate to 's' 34 return s.hashCode(); 35 } 36 37 @Override equals(@ullable Object other)38 public boolean equals(@Nullable Object other) { 39 if (other == null) { 40 return false; 41 } else if (other instanceof Base) { 42 return s.equals(((Base) other).s); 43 } else { 44 return false; 45 } 46 } 47 48 @Override compareTo(Base o)49 public int compareTo(Base o) { 50 return s.compareTo(o.s); 51 } 52 53 private static final long serialVersionUID = 0; 54 } 55