View Javadoc

1   /*
2    * Copyright (C) 2011 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.input;
18  
19  import com.google.common.base.Objects;
20  import org.joda.time.DateTime;
21  
22  import javax.annotation.Nullable;
23  
24  /**
25   * Input data describing details of a project version to create.
26   *
27   * @since v4.4
28   */
29  public class VersionInput {
30      private final String projectKey;
31      private final String name;
32      @Nullable
33      private final String description;
34      private final DateTime releaseDate;
35      private boolean isArchived;
36      private boolean isReleased;
37  
38      public VersionInput(String projectKey, String name, @Nullable String description, @Nullable DateTime releaseDate,
39                          boolean isArchived, boolean isReleased) {
40          this.projectKey = projectKey;
41          this.name = name;
42          this.description = description;
43          this.releaseDate = releaseDate;
44          this.isArchived = isArchived;
45          this.isReleased = isReleased;
46      }
47  
48      public static VersionInput create(String projectKey, String name, @Nullable String description, @Nullable DateTime releaseDate,
49                                        boolean archived, boolean release) {
50          return new VersionInput(projectKey, name, description, releaseDate, archived, release);
51      }
52  
53      public String getProjectKey() {
54          return projectKey;
55      }
56  
57      public String getName() {
58          return name;
59      }
60  
61      @Nullable
62      public String getDescription() {
63          return description;
64      }
65  
66      public DateTime getReleaseDate() {
67          return releaseDate;
68      }
69  
70      public boolean isArchived() {
71          return isArchived;
72      }
73  
74      public boolean isReleased() {
75          return isReleased;
76      }
77  
78      @Override
79      public String toString() {
80          return Objects.toStringHelper(this)
81                  .add("name", name)
82                  .add("projectKey", projectKey)
83                  .add("description", description)
84                  .add("releaseDate", releaseDate)
85                  .add("isArchived", isArchived)
86                  .add("isReleased", isReleased)
87                  .toString();
88      }
89  
90      @Override
91      public boolean equals(Object obj) {
92          if (obj instanceof VersionInput) {
93              VersionInput that = (VersionInput) obj;
94              return Objects.equal(this.projectKey, that.projectKey)
95                      && Objects.equal(this.name, that.name)
96                      && Objects.equal(this.releaseDate, that.releaseDate)
97                      && Objects.equal(this.isArchived, that.isArchived)
98                      && Objects.equal(this.isReleased, that.isReleased);
99          }
100         return false;
101     }
102 
103     @Override
104     public int hashCode() {
105         return Objects.hashCode(name, projectKey, description, releaseDate, isArchived, isReleased);
106     }
107 
108 
109 }