1f3d04ab0df6af74f9a11ea33927700b33d03072
[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.Set;
25
26 import static java.util.Objects.hash;
27
28 @Table(keyspace = "dox", name = "notification_subscribers")
29 public class SubscribersEntity {
30
31     @PartitionKey
32     @Column(name = "entity_id")
33     private String entityId;
34
35     @Column(name = "subscribers")
36     private Set<String> subscribers;
37
38     /**
39      * Every entity class must have a default constructor according to
40      * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
41      * Definition of mapped classes</a>.
42      */
43     public SubscribersEntity() {
44         // Don't delete! Default constructor is required by DataStax driver
45     }
46
47     public SubscribersEntity(String entityId, Set<String> subscribers) {
48         this.entityId = entityId;
49         this.subscribers = subscribers;
50     }
51
52     public String getEntityId() {
53         return entityId;
54     }
55
56     public void setEntityId(String entityId) {
57         this.entityId = entityId;
58     }
59
60     public Set<String> getSubscribers() {
61         return subscribers;
62     }
63
64     public void setSubscribers(Set<String> subscribers) {
65         this.subscribers = subscribers;
66     }
67
68     @Override
69     public boolean equals(Object o) {
70         if (this == o) return true;
71         if (o == null || getClass() != o.getClass()) return false;
72         SubscribersEntity that = (SubscribersEntity) o;
73         return Objects.equals(entityId, that.entityId) &&
74                 Objects.equals(subscribers, that.subscribers);
75     }
76
77     @Override
78     public int hashCode() {
79         return hash(entityId, subscribers);
80     }
81
82     @Override
83     public String toString() {
84         return "SubscribersEntity{" +
85                 "entityId='" + entityId + '\'' +
86                 ", subscribers=" + subscribers +
87                 '}';
88     }
89 }