View Javadoc

1   /*
2    * Copyright (C) 2012 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  package com.atlassian.jira.rest.client.api.domain;
17  
18  import com.atlassian.jira.rest.client.api.AddressableEntity;
19  import com.atlassian.jira.rest.client.api.NamedEntity;
20  import com.google.common.base.Objects;
21  
22  import java.net.URI;
23  
24  /**
25   * Basic information about a JIRA project's role.
26   */
27  public class BasicProjectRole implements AddressableEntity, NamedEntity {
28  
29      private final URI self;
30      private final String name;
31  
32      public BasicProjectRole(URI self, String name) {
33          this.self = self;
34          this.name = name;
35      }
36  
37      @Override
38      public URI getSelf() {
39          return self;
40      }
41  
42      /**
43       * @return the name of this project role.
44       */
45      @Override
46      public String getName() {
47          return name;
48      }
49  
50      @Override
51      public boolean equals(Object o) {
52          if (o instanceof BasicProjectRole) {
53              final BasicProjectRole that = (BasicProjectRole) o;
54              return Objects.equal(this.self, that.self)
55                      && Objects.equal(this.name, that.name);
56          }
57          return false;
58      }
59  
60      @Override
61      public int hashCode() {
62          return Objects.hashCode(super.hashCode(), self, name);
63      }
64  
65      @Override
66      public String toString() {
67          return getToStringHelper().toString();
68      }
69  
70      protected Objects.ToStringHelper getToStringHelper() {
71          return Objects.toStringHelper(this)
72                  .add("self", self)
73                  .add("name", name);
74      }
75  }