View Javadoc

1   /*
2    * Copyright (C) 2010 Atlassian
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.atlassian.jira.rest.client.api.domain;
18  
19  import com.atlassian.jira.rest.client.api.AddressableEntity;
20  import com.atlassian.jira.rest.client.api.NamedEntity;
21  import com.google.common.base.Objects;
22  
23  import javax.annotation.Nullable;
24  import java.net.URI;
25  
26  /**
27   * Basic information about a project component
28   *
29   * @since v0.1
30   */
31  public class BasicComponent implements AddressableEntity, NamedEntity {
32      @Nullable
33      private final Long id;
34      private final URI self;
35      private final String name;
36      @Nullable
37      private final String description;
38  
39      public BasicComponent(URI self, @Nullable Long id, String name, @Nullable String description) {
40          this.self = self;
41          this.id = id;
42          this.name = name;
43          this.description = description;
44      }
45  
46      @Override
47      public URI getSelf() {
48          return self;
49      }
50  
51      public String getName() {
52          return name;
53      }
54  
55      @Nullable
56      public Long getId() {
57          return id;
58      }
59  
60      /**
61       * @return optional description for this project (as defined by the project admin)
62       */
63      @Nullable
64      public String getDescription() {
65          return description;
66      }
67  
68      @Override
69      public String toString() {
70          return Objects.toStringHelper(this).
71                  add("id", id).
72                  add("self", self).
73                  add("name", name).
74                  add("description", description).
75                  toString();
76      }
77  
78      @Override
79      public boolean equals(Object obj) {
80          if (obj instanceof BasicComponent) {
81              BasicComponent that = (BasicComponent) obj;
82              return Objects.equal(this.self, that.self)
83                      && Objects.equal(this.id, that.id)
84                      && Objects.equal(this.name, that.name)
85                      && Objects.equal(this.description, that.description);
86          }
87          return false;
88      }
89  
90      @Override
91      public int hashCode() {
92          return Objects.hashCode(self, name, description);
93      }
94  
95  }