001/*
002 * Copyright (C) 2010 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.collect.testing;
018
019import com.google.common.annotations.GwtCompatible;
020import java.io.Serializable;
021
022/**
023 * Simple base class to verify that we handle generics correctly.
024 *
025 * @author Kevin Bourrillion
026 */
027@GwtCompatible
028public class BaseComparable implements Comparable<BaseComparable>, Serializable {
029  private final String s;
030
031  public BaseComparable(String s) {
032    this.s = s;
033  }
034
035  @Override
036  public int hashCode() { // delegate to 's'
037    return s.hashCode();
038  }
039
040  @Override
041  public boolean equals(Object other) {
042    if (other == null) {
043      return false;
044    } else if (other instanceof BaseComparable) {
045      return s.equals(((BaseComparable) other).s);
046    } else {
047      return false;
048    }
049  }
050
051  @Override
052  public int compareTo(BaseComparable o) {
053    return s.compareTo(o.s);
054  }
055
056  private static final long serialVersionUID = 0;
057}