View Javadoc

1   /*
2    * Copyright 2011 Vincent Behar
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 org.rundeck.api.domain;
17  
18  import java.io.Serializable;
19  import org.apache.commons.lang.StringUtils;
20  
21  /**
22   * Represents a RunDeck job
23   * 
24   * @author Vincent Behar
25   */
26  public class RundeckJob implements Serializable {
27  
28      private static final long serialVersionUID = 1L;
29  
30      private String id;
31  
32      private String name;
33  
34      private String group;
35  
36      private String project;
37  
38      private String description;
39  
40      /**
41       * @return the fullname : group + name (exact format is : "group/name")
42       */
43      public String getFullName() {
44          StringBuilder fullName = new StringBuilder();
45          if (StringUtils.isNotBlank(group)) {
46              fullName.append(group).append("/");
47          }
48          fullName.append(name);
49          return fullName.toString();
50      }
51  
52      public String getId() {
53          return id;
54      }
55  
56      public void setId(String id) {
57          this.id = id;
58      }
59  
60      public String getName() {
61          return name;
62      }
63  
64      public void setName(String name) {
65          this.name = name;
66      }
67  
68      public String getGroup() {
69          return group;
70      }
71  
72      public void setGroup(String group) {
73          this.group = group;
74      }
75  
76      public String getProject() {
77          return project;
78      }
79  
80      public void setProject(String project) {
81          this.project = project;
82      }
83  
84      public String getDescription() {
85          return description;
86      }
87  
88      public void setDescription(String description) {
89          this.description = description;
90      }
91  
92      @Override
93      public String toString() {
94          return "RundeckJob [id=" + id + ", name=" + name + ", group=" + group + ", project=" + project
95                 + ", description=" + description + "]";
96      }
97  
98      @Override
99      public int hashCode() {
100         final int prime = 31;
101         int result = 1;
102         result = prime * result + ((description == null) ? 0 : description.hashCode());
103         result = prime * result + ((group == null) ? 0 : group.hashCode());
104         result = prime * result + ((id == null) ? 0 : id.hashCode());
105         result = prime * result + ((name == null) ? 0 : name.hashCode());
106         result = prime * result + ((project == null) ? 0 : project.hashCode());
107         return result;
108     }
109 
110     @Override
111     public boolean equals(Object obj) {
112         if (this == obj)
113             return true;
114         if (obj == null)
115             return false;
116         if (getClass() != obj.getClass())
117             return false;
118         RundeckJob other = (RundeckJob) obj;
119         if (description == null) {
120             if (other.description != null)
121                 return false;
122         } else if (!description.equals(other.description))
123             return false;
124         if (group == null) {
125             if (other.group != null)
126                 return false;
127         } else if (!group.equals(other.group))
128             return false;
129         if (id == null) {
130             if (other.id != null)
131                 return false;
132         } else if (!id.equals(other.id))
133             return false;
134         if (name == null) {
135             if (other.name != null)
136                 return false;
137         } else if (!name.equals(other.name))
138             return false;
139         if (project == null) {
140             if (other.project != null)
141                 return false;
142         } else if (!project.equals(other.project))
143             return false;
144         return true;
145     }
146 
147 }