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 private final String id;
31  	private final String label;
32  	@Nullable private final String title;
33  	@Nullable private final String iconClass;
34  
35  	public OperationHeader(@Nullable final String id, final String label, @Nullable final String title, @Nullable final String iconClass) {
36  		this.id = id;
37  		this.label = label;
38  		this.title = title;
39  		this.iconClass = iconClass;
40  	}
41  
42  	@Nullable
43  	@Override
44  	public String getId() {
45  		return id;
46  	}
47  
48  	@Override
49  	public <T> Optional<T> accept(final OperationVisitor<T> visitor) {
50  		return visitor.visit(this);
51  	}
52  
53  	public String getLabel() {
54  		return label;
55  	}
56  
57  	@Nullable
58  	public String getTitle() {
59  		return title;
60  	}
61  
62  	@Nullable
63  	public String getIconClass() {
64  		return iconClass;
65  	}
66  
67  	@Override
68  	public String toString() {
69  		return Objects.toStringHelper(this)
70  				.add("id", id)
71  				.add("label", label)
72  				.add("title", title)
73  				.add("iconClass", iconClass)
74  				.toString();
75  	}
76  
77  	@Override
78  	public boolean equals(Object o) {
79  		if (o instanceof OperationHeader) {
80  			OperationHeader that = (OperationHeader) o;
81  			return Objects.equal(id, that.id)
82  					&& Objects.equal(label, that.label)
83  					&& Objects.equal(title, that.title)
84  					&& Objects.equal(iconClass, that.iconClass);
85  		}
86  		return false;
87  	}
88  
89  	@Override
90  	public int hashCode() {
91  		return Objects.hashCode(id, label, title, iconClass);
92  	}
93  }