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.domain;
18  
19  import com.atlassian.jira.rest.client.AddressableEntity;
20  import com.google.common.base.Objects;
21  import org.joda.time.DateTime;
22  
23  import javax.annotation.Nullable;
24  import java.net.URI;
25  
26  /**
27   * Complete information about a version defined for a JIRA project
28   *
29   * @since v0.1
30   */
31  public class Version implements AddressableEntity {
32  	private final URI self;
33  	private final String description;
34  	private final String name;
35  	private final boolean isArchived;
36  	private final boolean isReleased;
37  	@Nullable
38  	private final DateTime releaseDate;
39  
40  	public Version(URI self, String name, String description, boolean archived, boolean released, DateTime releaseDate) {
41  		this.self = self;
42  		this.description = description;
43  		this.name = name;
44  		isArchived = archived;
45  		isReleased = released;
46  		this.releaseDate = releaseDate;
47  	}
48  
49  	@Override
50  	public URI getSelf() {
51  		return self;
52  	}
53  
54  	public String getDescription() {
55  		return description;
56  	}
57  
58  	public String getName() {
59  		return name;
60  	}
61  
62  	public boolean isArchived() {
63  		return isArchived;
64  	}
65  
66  	public boolean isReleased() {
67  		return isReleased;
68  	}
69  
70  	@Nullable
71  	public DateTime getReleaseDate() {
72  		return releaseDate;
73  	}
74  
75  	@Override
76  	public String toString() {
77  		return Objects.toStringHelper(this).
78  				add("self", self).
79  				add("name", name).
80  				add("description", description).
81  				add("isArchived", isArchived).
82  				add("isReleased", isReleased).
83  				add("releaseDate", releaseDate).
84  				toString();
85  	}
86  
87  	@Override
88  	public boolean equals(Object obj) {
89  		if (obj instanceof Version) {
90  			Version that = (Version) obj;
91  			return Objects.equal(this.self, that.self)
92  					&& Objects.equal(this.name, that.name)
93  					&& Objects.equal(this.description, that.description)
94  					&& Objects.equal(this.isArchived, that.isArchived)
95  					&& Objects.equal(this.isReleased, that.isReleased)
96  					&& Objects.equal(this.releaseDate, that.releaseDate);
97  		}
98  		return false;
99  	}
100 
101 	@Override
102 	public int hashCode() {
103 		return Objects.hashCode(self, name, description, isArchived, isReleased, releaseDate);
104 	}
105 
106 }