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