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.IdentifiableEntity;
19  import com.google.common.base.Objects;
20  
21  import java.net.URI;
22  
23  /**
24   * Represents Filter
25   *
26   * @since 2.0
27   */
28  public class Filter extends AddressableNamedEntity implements IdentifiableEntity<Long> {
29  	private final Long id;
30  	private final String description;
31  	private final String jql;
32  	private final URI viewUrl;
33  	private final URI searchUrl;
34  	private final BasicUser owner;
35  	private final boolean favourite;
36  
37  	public Filter(URI self, Long id, String name, String description, String jql, URI viewUrl, URI searchUrl, BasicUser owner, boolean favourite) {
38  		super(self, name);
39  		this.id = id;
40  		this.description = description;
41  		this.jql = jql;
42  		this.viewUrl = viewUrl;
43  		this.searchUrl = searchUrl;
44  		this.owner = owner;
45  		this.favourite = favourite;
46  	}
47  
48  	@Override
49  	public Long getId() {
50  		return id;
51  	}
52  
53  	@SuppressWarnings("UnusedDeclaration")
54  	public String getJql() {
55  		return jql;
56  	}
57  
58  	@SuppressWarnings("UnusedDeclaration")
59  	public URI getViewUrl() {
60  		return viewUrl;
61  	}
62  
63  	@SuppressWarnings("UnusedDeclaration")
64  	public URI getSearchUrl() {
65  		return searchUrl;
66  	}
67  
68  	public String getDescription() {
69  		return description;
70  	}
71  
72  	@SuppressWarnings("UnusedDeclaration")
73  	public BasicUser getOwner() {
74  		return owner;
75  	}
76  
77  	@SuppressWarnings("UnusedDeclaration")
78  	public boolean isFavourite() {
79  		return favourite;
80  	}
81  
82  	@Override
83  	protected Objects.ToStringHelper getToStringHelper() {
84  		return super.getToStringHelper()
85  				.add("id", id)
86  				.add("description", description)
87  				.add("jql", jql)
88  				.add("viewUrl", viewUrl)
89  				.add("searchUrl", searchUrl)
90  				.add("owner", owner)
91  				.add("favourite", favourite);
92  	}
93  
94  	@Override
95  	public boolean equals(Object obj) {
96  		if (obj instanceof Filter) {
97  			Filter that = (Filter) obj;
98  			return super.equals(that)
99  					&& Objects.equal(this.id, that.id)
100 					&& Objects.equal(this.description, that.description)
101 					&& Objects.equal(this.jql, that.jql)
102 					&& Objects.equal(this.viewUrl, that.viewUrl)
103 					&& Objects.equal(this.searchUrl, that.searchUrl)
104 					&& Objects.equal(this.owner, that.owner)
105 					&& Objects.equal(this.favourite, that.favourite);
106 		}
107 		return false;
108 	}
109 
110 	@Override
111 	public int hashCode() {
112 		return Objects.hashCode(super.hashCode(), id, description, jql, searchUrl, viewUrl, owner, favourite);
113 	}
114 }