bdd2ad4fadbf55a652f4836bd03ee4e7793c3ee7
[sdc.git] /
1 /*
2  * Copyright © 2016-2017 European Support Limited
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
17 package org.openecomp.sdc.notification.dao.types;
18
19 import com.datastax.driver.mapping.annotations.Column;
20 import com.datastax.driver.mapping.annotations.PartitionKey;
21 import com.datastax.driver.mapping.annotations.Table;
22
23 import java.util.Objects;
24 import java.util.UUID;
25
26 @Table(keyspace = "dox", name = "last_notification")
27 public class LastSeenNotificationEntity {
28   public static final String ENTITY_TYPE = "Event Notification";
29
30   @PartitionKey
31   @Column(name = "owner_id")
32   private String ownerId;
33
34   @Column(name = "event_id")
35   private UUID lastEventId;
36
37   /**
38    * Every entity class must have a default constructor according to
39    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
40    * Definition of mapped classes</a>.
41    */
42   public LastSeenNotificationEntity() {
43     // Don't delete! Default constructor is required by DataStax driver
44   }
45
46   /**
47    * Instantiates a new Notification entity.
48    *
49    * @param ownerId      the owner id
50    * @param lastEventId  the last event id
51    */
52   public LastSeenNotificationEntity(String ownerId, UUID lastEventId) {
53     this.ownerId = ownerId;
54     this.lastEventId = lastEventId;
55   }
56
57   public String getOwnerId() {
58     return ownerId;
59   }
60
61   public void setOwnerId(String ownerId) {
62     this.ownerId = ownerId;
63   }
64
65   public UUID getLastEventId() {
66     return lastEventId;
67   }
68
69   public void setLastEventId(UUID lastEventId) {
70     this.lastEventId = lastEventId;
71   }
72
73   @Override
74   public boolean equals(Object o) {
75     if (this == o) return true;
76     if (o == null || getClass() != o.getClass()) return false;
77     LastSeenNotificationEntity that = (LastSeenNotificationEntity) o;
78     return Objects.equals(ownerId, that.ownerId) &&
79             Objects.equals(lastEventId, that.lastEventId);
80   }
81
82   @Override
83   public int hashCode() {
84     return Objects.hash(ownerId, lastEventId);
85   }
86
87   @Override
88   public String toString() {
89     return "LastSeenNotificationEntity {"
90         + "ownerId='" + ownerId + '\''
91        + '}';
92   }
93 }