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 java.util.ArrayList;
20  import java.util.List;
21  
22  /**
23   * Represents a portion of the Rundeck (events) history
24   * 
25   * @author Vincent Behar
26   */
27  public class RundeckHistory implements Serializable {
28  
29      private static final long serialVersionUID = 1L;
30  
31      private List<RundeckEvent> events;
32  
33      private int count;
34  
35      private int total;
36  
37      private int max;
38  
39      private int offset;
40  
41      public void addEvent(RundeckEvent event) {
42          if (events == null) {
43              events = new ArrayList<RundeckEvent>();
44          }
45          events.add(event);
46      }
47  
48      public List<RundeckEvent> getEvents() {
49          return events;
50      }
51  
52      public void setEvents(List<RundeckEvent> events) {
53          this.events = events;
54      }
55  
56      public int getCount() {
57          return count;
58      }
59  
60      public void setCount(int count) {
61          this.count = count;
62      }
63  
64      public int getTotal() {
65          return total;
66      }
67  
68      public void setTotal(int total) {
69          this.total = total;
70      }
71  
72      public int getMax() {
73          return max;
74      }
75  
76      public void setMax(int max) {
77          this.max = max;
78      }
79  
80      public int getOffset() {
81          return offset;
82      }
83  
84      public void setOffset(int offset) {
85          this.offset = offset;
86      }
87  
88      @Override
89      public String toString() {
90          return "RundeckHistory [count=" + count + ", max=" + max + ", offset=" + offset + ", total=" + total + "]";
91      }
92  
93      @Override
94      public int hashCode() {
95          final int prime = 31;
96          int result = 1;
97          result = prime * result + count;
98          result = prime * result + ((events == null) ? 0 : events.hashCode());
99          result = prime * result + max;
100         result = prime * result + offset;
101         result = prime * result + total;
102         return result;
103     }
104 
105     @Override
106     public boolean equals(Object obj) {
107         if (this == obj)
108             return true;
109         if (obj == null)
110             return false;
111         if (getClass() != obj.getClass())
112             return false;
113         RundeckHistory other = (RundeckHistory) obj;
114         if (count != other.count)
115             return false;
116         if (events == null) {
117             if (other.events != null)
118                 return false;
119         } else if (!events.equals(other.events))
120             return false;
121         if (max != other.max)
122             return false;
123         if (offset != other.offset)
124             return false;
125         if (total != other.total)
126             return false;
127         return true;
128     }
129 
130 }