private static NotificationServerSync deepCopy(NotificationServerSync source) { if (source == null) { return null; } NotificationServerSync copy = new NotificationServerSync(); copy.setResponseStatus(source.getResponseStatus()); if (source.getNotifications() != null) { copy.setNotifications(new ArrayList<>(source.getNotifications())); } if (source.getAvailableTopics() != null) { copy.setAvailableTopics(new ArrayList<>(source.getAvailableTopics())); } return copy; }
NotificationServerSync notificationResponse = response.getNotificationSync(); if (notificationResponse == null) { notificationResponse = new NotificationServerSync(); response.setNotificationSync(notificationResponse); List<Notification> notifications = notificationResponse.getNotifications(); if (notifications == null) { notifications = new ArrayList<Notification>(); notificationResponse.setNotifications(notifications); notificationResponse.setResponseStatus(SyncResponseStatus.DELTA); LOG.debug("Updated sync response {}", response); return response;
NotificationServerSync response = new NotificationServerSync(); response.setResponseStatus(SyncResponseStatus.NO_DELTA); notifications.add(convertNotification(notificationDto)); response.setNotifications(notifications); response.setAvailableTopics(topicList); response.setResponseStatus(SyncResponseStatus.DELTA);
private static NotificationSyncResponse convert(NotificationServerSync source) { if (source == null) { return null; } NotificationSyncResponse sync = new NotificationSyncResponse(); sync.setResponseStatus(convert(source.getResponseStatus())); if (source.getAvailableTopics() != null) { List<Topic> topics = new ArrayList<>(source.getAvailableTopics().size()); for (org.kaaproject.kaa.server.sync.Topic topic : source.getAvailableTopics()) { topics.add(new Topic( topic.getIdAsLong(), topic.getName(), convert(topic.getSubscriptionType()))); } sync.setAvailableTopics(topics); } if (source.getNotifications() != null) { List<Notification> notifications = new ArrayList<>(source.getNotifications().size()); for (org.kaaproject.kaa.server.sync.Notification notification : source.getNotifications()) { notifications.add(new Notification( notification.getTopicIdAsLong(), convert(notification.getType()), notification.getUid(), notification.getSeqNumber(), notification.getBody())); } sync.setNotifications(notifications); } return sync; }
&& response.getNotificationSync().getResponseStatus() != SyncResponseStatus.NO_DELTA) { return true;
? !notificationSync.equals(that.notificationSync) : that.notificationSync != null) { return false;
@Override public int hashCode() { int result = requestId; result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0); result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0); result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 0); result = 31 * result + (notificationSync != null ? notificationSync.hashCode() : 0); result = 31 * result + (userSync != null ? userSync.hashCode() : 0); result = 31 * result + (eventSync != null ? eventSync.hashCode() : 0); result = 31 * result + (redirectSync != null ? redirectSync.hashCode() : 0); result = 31 * result + (logSync != null ? logSync.hashCode() : 0); return result; }
final int extPosition = buf.position(); SyncResponseStatus status = notificationSync.getResponseStatus(); switch (status) { case NO_DELTA: break; if (notificationSync.getAvailableTopics() != null) { buf.put(NF_TOPICS_FIELD_ID); buf.put(NOTHING); buf.putShort((short) notificationSync.getAvailableTopics().size()); for (Topic t : notificationSync.getAvailableTopics()) { buf.putLong(t.getIdAsLong()); buf.put(t.getSubscriptionType() == SubscriptionType.MANDATORY ? MANDATORY : OPTIONAL); if (notificationSync.getNotifications() != null) { buf.put(NF_NOTIFICATIONS_FIELD_ID); buf.put(NOTHING); buf.putShort((short) notificationSync.getNotifications().size()); for (Notification nf : notificationSync.getNotifications()) { buf.putInt((nf.getSeqNumber() != null) ? nf.getSeqNumber() : 0); buf.put(nf.getType() == NotificationType.SYSTEM ? SYSTEM : CUSTOM);