View Javadoc

1   /*
2    * Copyright (C) 2014 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.google.common.base.Objects;
20  import com.google.common.base.Optional;
21  
22  import javax.annotation.Nullable;
23  
24  /**
25   * Represents operations header
26   *
27   * @since 2.0
28   */
29  public class OperationHeader implements Operation {
30      @Nullable
31      private final String id;
32      private final String label;
33      @Nullable
34      private final String title;
35      @Nullable
36      private final String iconClass;
37  
38      public OperationHeader(@Nullable final String id, final String label, @Nullable final String title, @Nullable final String iconClass) {
39          this.id = id;
40          this.label = label;
41          this.title = title;
42          this.iconClass = iconClass;
43      }
44  
45      @Nullable
46      @Override
47      public String getId() {
48          return id;
49      }
50  
51      @Override
52      public <T> Optional<T> accept(final OperationVisitor<T> visitor) {
53          return visitor.visit(this);
54      }
55  
56      public String getLabel() {
57          return label;
58      }
59  
60      @Nullable
61      public String getTitle() {
62          return title;
63      }
64  
65      @Nullable
66      public String getIconClass() {
67          return iconClass;
68      }
69  
70      @Override
71      public String toString() {
72          return Objects.toStringHelper(this)
73                  .add("id", id)
74                  .add("label", label)
75                  .add("title", title)
76                  .add("iconClass", iconClass)
77                  .toString();
78      }
79  
80      @Override
81      public boolean equals(Object o) {
82          if (o instanceof OperationHeader) {
83              OperationHeader that = (OperationHeader) o;
84              return Objects.equal(id, that.id)
85                      && Objects.equal(label, that.label)
86                      && Objects.equal(title, that.title)
87                      && Objects.equal(iconClass, that.iconClass);
88          }
89          return false;
90      }
91  
92      @Override
93      public int hashCode() {
94          return Objects.hashCode(id, label, title, iconClass);
95      }
96  }