View Javadoc
1   /*
2    * Copyright (C) 2003-2014 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero General Public License
15   * along with this program. If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.calendar.model;
18  
19  import java.io.Serializable;
20  import java.util.Objects;
21  
22  @SuppressWarnings("serial")
23  public abstract class AbstractModel implements Serializable {
24  
25    private String id;
26  
27    private String ds;
28  
29    private long lastModified;
30  
31    public AbstractModel(String id) {
32      this.id = id;
33    }
34    
35    public String getId() {
36      return id;
37    }
38  
39    public void setId(String id) {
40      this.id = id;
41    }
42  
43    public void setDS(String dsName) {
44      this.ds = dsName;
45    }
46  
47    public String getDS() {
48      return ds;
49    }
50  
51    public String getCompositeId() {
52      return new CompositeID(getId(), getDS()).toString();
53    }
54  
55    public long getLastModified() {    
56      return lastModified;
57    }
58  
59    public void setLastModified(long lastModified) {
60      lastModified = (lastModified / 1000) * 1000;
61      this.lastModified = lastModified;
62    }
63  
64    @Override
65    public boolean equals(Object o) {
66      if (this == o) return true;
67      if (o == null || getClass() != o.getClass()) return false;
68      AbstractModel that = (AbstractModel) o;
69      return lastModified == that.lastModified &&
70              Objects.equals(id, that.id) &&
71              Objects.equals(ds, that.ds);
72    }
73  
74    @Override
75    public int hashCode() {
76      return Objects.hash(id, ds, lastModified);
77    }
78  }