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  import java.util.LinkedHashSet;
    20  import java.util.Set;
    21  import java.util.TreeSet;
    22
    23  public class Blog {
    24
    25      private String name;
    26      private Set<Post> posts = new TreeSet<Post>();
    27      public Set<Integer> numbers = new LinkedHashSet<Integer>();
    28      private TreeSet<String> labels = new TreeSet<String>();
    29
    30      public Blog() {
    31          name = "SuperBlog";
    32      }
    33
    34      public Blog(String name) {
    35          this.name = name;
    36      }
    37
    38      public void addPost(Post p) {
    39          posts.add(p);
    40      }
    41
    42      public Set<Post> getPosts() {
    43          return posts;
    44      }
    45
    46      public String getName() {
    47          return name;
    48      }
    49
    50      public void setName(String name) {
    51          this.name = name;
    52      }
    53
    54      public void setPosts(Set<Post> posts) {
    55          this.posts = posts;
    56      }
    57
    58      public TreeSet<String> getLabels() {
    59          return labels;
    60      }
    61
    62      public void setLabels(TreeSet<String> labels) {
    63          this.labels = labels;
    64      }
    65
    66      @Override
    67      public boolean equals(Object obj) {
    68          return name.equals(obj.toString());
    69      }
    70
    71      @Override
    72      public int hashCode() {
    73          return name.hashCode();
    74      }
    75
    76      @Override
    77      public String toString() {
    78          return "Blog '" + name + "'";
    79      }
    80  }