View Javadoc

    1   /**
    2    * Copyright (c) 2008-2011, http://www.snakeyaml.org
    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 org.yaml.snakeyaml.issues.issue73;
    18
    19  class Post implements Comparable<Post> {
    20
    21      private String title;
    22      private String text;
    23
    24      protected Post() {
    25      }
    26
    27      public Post(String title, String text) {
    28          super();
    29          this.title = title;
    30          this.text = text;
    31      }
    32
    33      public String getTitle() {
    34          return title;
    35      }
    36
    37      public String getText() {
    38          return text;
    39      }
    40
    41      public int compareTo(Post o) {
    42          return title.compareTo(o.title);
    43      }
    44
    45      @Override
    46      public boolean equals(Object obj) {
    47          if (obj instanceof Post) {
    48              return toString().equals(obj.toString());
    49          } else {
    50              return false;
    51          }
    52      }
    53
    54      @Override
    55      public int hashCode() {
    56          return toString().hashCode();
    57      }
    58
    59      @Override
    60      public String toString() {
    61          return "Post " + title + " " + text;
    62      }
    63  }