diff options
author | vempo <vitaliy.emporopulo@amdocs.com> | 2017-12-31 11:12:53 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-31 11:29:31 +0000 |
commit | 0b566202130593dffbc9590dacea2e57083fd4d9 (patch) | |
tree | 48902f45cee6919d6d0aa29eba7f7167ab0a9a60 /openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main | |
parent | 0c350f1e8a1306a1749a7e46e0bd4ded1c8c64e6 (diff) |
Default ctors in notification-api module
Change-Id: I823348c05a367ed876a63aaa146a98d1cb869cd8
Issue-ID: SDC-343
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main')
3 files changed, 61 insertions, 73 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java index d6e717d1b3..bdd2ad4fad 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2017 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ package org.openecomp.sdc.notification.dao.types; @@ -38,7 +34,13 @@ public class LastSeenNotificationEntity { @Column(name = "event_id") private UUID lastEventId; + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ public LastSeenNotificationEntity() { + // Don't delete! Default constructor is required by DataStax driver } /** @@ -69,29 +71,17 @@ public class LastSeenNotificationEntity { } @Override - public boolean equals(Object other) { - if (Objects.equals(this, other)) { - return true; - } - - if (Objects.equals(getClass(), other.getClass())) { - return false; - } - - LastSeenNotificationEntity that = (LastSeenNotificationEntity) other; - - if (Objects.equals(ownerId, that.ownerId)) { - return false; - } - - return !Objects.equals(lastEventId, that.lastEventId); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LastSeenNotificationEntity that = (LastSeenNotificationEntity) o; + return Objects.equals(ownerId, that.ownerId) && + Objects.equals(lastEventId, that.lastEventId); } @Override public int hashCode() { - int result = ownerId != null ? ownerId.hashCode() : 0; - result = 31 * result + (lastEventId != null ? lastEventId.hashCode() : 0); - return result; + return Objects.hash(ownerId, lastEventId); } @Override diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java index cc9309be97..85af302205 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2017 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ package org.openecomp.sdc.notification.dao.types; @@ -53,7 +49,13 @@ public class NotificationEntity { @Column(name = "originator_id") private String originatorId; + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ public NotificationEntity() { + // Don't delete! Default constructor is required by DataStax driver } public NotificationEntity(String ownerId) { @@ -68,7 +70,8 @@ public class NotificationEntity { * @param eventType the event type * @param originatorId the originator id */ - public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, String eventAttributes) { + public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, + String eventAttributes) { this.ownerId = ownerId; this.read = read; this.eventId = eventId; @@ -133,49 +136,23 @@ public class NotificationEntity { this.originatorId = originatorId; } + @Override - public boolean equals(Object other) { - if (Objects.equals(this, other)) { - return true; - } - - if (other == null){ - return false; - } - - if (Objects.equals(getClass(), other.getClass())) { - return false; - } - - NotificationEntity that = (NotificationEntity) other; - - if (Objects.equals(ownerId, that.ownerId)) { - return false; - } - if (read != that.read) { - return false; - } - if (Objects.equals(eventId, that.eventId)) { - return false; - } - if (Objects.equals(eventType, that.eventType)) { - return false; - } - if (Objects.equals(eventAttributes, that.eventAttributes)) { - return false; - } - if (Objects.equals(originatorId, that.originatorId)) { - return false; - } - - return true; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NotificationEntity that = (NotificationEntity) o; + return read == that.read && + Objects.equals(ownerId, that.ownerId) && + Objects.equals(eventId, that.eventId) && + Objects.equals(eventType, that.eventType) && + Objects.equals(eventAttributes, that.eventAttributes) && + Objects.equals(originatorId, that.originatorId); } @Override public int hashCode() { - int result = ownerId != null ? ownerId.hashCode() : 0; - result = 31 * result + (eventId != null ? eventId.hashCode() : 0); - return result; + return Objects.hash(ownerId, read, eventId, eventType, eventAttributes, originatorId); } @Override diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java index d858cbd9eb..1f3d04ab0d 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.openecomp.sdc.notification.dao.types; import com.datastax.driver.mapping.annotations.Column; @@ -19,8 +35,13 @@ public class SubscribersEntity { @Column(name = "subscribers") private Set<String> subscribers; - + /** + * Every entity class must have a default constructor according to + * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/"> + * Definition of mapped classes</a>. + */ public SubscribersEntity() { + // Don't delete! Default constructor is required by DataStax driver } public SubscribersEntity(String entityId, Set<String> subscribers) { |