Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-sdc-notification-lib / openecomp-sdc-notification-api / src / main / java / org / openecomp / sdc / notification / dao / types / LastSeenNotificationEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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.openecomp.sdc.notification.dao.types;
22
23 import com.datastax.driver.mapping.annotations.Column;
24 import com.datastax.driver.mapping.annotations.PartitionKey;
25 import com.datastax.driver.mapping.annotations.Table;
26
27 import java.util.Objects;
28 import java.util.UUID;
29
30 @Table(keyspace = "dox", name = "last_notification")
31 public class LastSeenNotificationEntity {
32   public static final String ENTITY_TYPE = "Event Notification";
33
34   @PartitionKey
35   @Column(name = "owner_id")
36   private String ownerId;
37
38   @Column(name = "event_id")
39   private UUID lastEventId;
40
41   public LastSeenNotificationEntity() {
42   }
43
44   /**
45    * Instantiates a new Notification entity.
46    *
47    * @param ownerId      the owner id
48    * @param lastEventId  the last event id
49    */
50   public LastSeenNotificationEntity(String ownerId, UUID lastEventId) {
51     this.ownerId = ownerId;
52     this.lastEventId = lastEventId;
53   }
54
55   public String getOwnerId() {
56     return ownerId;
57   }
58
59   public void setOwnerId(String ownerId) {
60     this.ownerId = ownerId;
61   }
62
63   public UUID getLastEventId() {
64     return lastEventId;
65   }
66
67   public void setLastEventId(UUID lastEventId) {
68     this.lastEventId = lastEventId;
69   }
70
71   @Override
72   public boolean equals(Object other) {
73     if (Objects.equals(this, other)) {
74       return true;
75     }
76
77     if (Objects.equals(getClass(), other.getClass())) {
78       return false;
79     }
80
81     LastSeenNotificationEntity that = (LastSeenNotificationEntity) other;
82
83     if (Objects.equals(ownerId, that.ownerId)) {
84       return false;
85     }
86
87     return !Objects.equals(lastEventId, that.lastEventId);
88   }
89
90   @Override
91   public int hashCode() {
92     int result = ownerId != null ? ownerId.hashCode() : 0;
93     result = 31 * result + (lastEventId != null ? lastEventId.hashCode() : 0);
94     return result;
95   }
96
97   @Override
98   public String toString() {
99     return "LastSeenNotificationEntity {"
100         + "ownerId='" + ownerId + '\''
101        + '}';
102   }
103 }