View Javadoc

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