31728bc2fc89ec3fba06397b090c2f0efb8363d2
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * feature-active-standby-management
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.drools.activestandby;
22
23 import java.util.Date;
24
25 public class DroolsPdpImpl extends DroolsPdpObject {
26
27     private boolean designated;
28     private int priority;
29     private Date updatedDate;
30     private Date designatedDate;
31     private String pdpId;
32     private String site;
33
34     /**
35      * Contructor.
36      * 
37      * @param pdpId ID for the PDP
38      * @param designated is designated
39      * @param priority priority
40      * @param updatedDate date updated
41      */
42     public DroolsPdpImpl(String pdpId, boolean designated, int priority, Date updatedDate) {
43         this.pdpId = pdpId;
44         this.designated = designated;
45         this.priority = priority;
46         this.updatedDate = updatedDate;
47         //When this is translated to a TimeStamp in MySQL, it assumes the date is relative
48         //to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
49         //which is an invalid value for the MySql TimeStamp 
50         this.designatedDate = new Date(864000000);
51
52     }
53     
54     @Override
55     public boolean isDesignated() {
56
57         return designated;
58     }
59
60     @Override
61     public int getPriority() {
62         return priority;
63     }
64     
65     @Override
66     public void setUpdatedDate(Date date) {
67         this.updatedDate = date;
68     }
69     
70     @Override
71     public Date getUpdatedDate() {
72         return updatedDate;
73     }
74
75     @Override
76     public String getPdpId() {
77         return pdpId;
78     }
79     
80     @Override
81     public void setDesignated(boolean isDesignated) {
82         this.designated = isDesignated;
83
84     }
85
86     @Override
87     public String getSiteName() {
88         return site;
89     }
90     
91     @Override
92     public void setSiteName(String siteName) {
93         this.site = siteName;
94
95     }
96     
97     @Override
98     public Date getDesignatedDate() {
99         return designatedDate;
100     }
101     
102     @Override
103     public void setDesignatedDate(Date designatedDate) {
104         this.designatedDate = designatedDate;
105
106     }
107
108     @Override
109     public boolean equals(Object obj) {
110
111
112         if (obj instanceof DroolsPdp) {
113             DroolsPdpImpl temp = (DroolsPdpImpl) obj;
114             return this.pdpId.equals(temp.getPdpId());
115         } else {
116             return false;
117         }
118     }
119
120     @Override
121     public int hashCode() {
122         final int prime = 31;
123         int result = 1;
124         result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
125         return result;
126     }
127 }