/** * This method convert list of dto objects to model object. * * @param notificationList the notification list * @return converted list of model objects */ public static List<MongoNotification> convertToModelList( List<NotificationDto> notificationList) { List<MongoNotification> notifications = null; if (notificationList != null && !notificationList.isEmpty()) { notifications = new ArrayList<>(); for (NotificationDto dto : notificationList) { notifications.add(new MongoNotification(dto)); } } return notifications; }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof MongoEndpointNotification)) { return false; } MongoEndpointNotification that = (MongoEndpointNotification) object; if (!Arrays.equals(endpointKeyHash, that.endpointKeyHash)) { return false; } return !(notification != null ? !notification.equals(that.notification) : that.notification != null); }
@Override public int hashCode() { int result = endpointKeyHash != null ? Arrays.hashCode(endpointKeyHash) : 0; result = 31 * result + (notification != null ? notification.hashCode() : 0); return result; }
@Override public EndpointNotificationDto toDto() { EndpointNotificationDto dto = new EndpointNotificationDto(); dto.setId(id); dto.setEndpointKeyHash(getArrayCopy(endpointKeyHash)); dto.setNotificationDto(notification != null ? notification.toDto() : null); return dto; } }
@Override public MongoNotification save(NotificationDto notification) { return save(new MongoNotification(notification)); } }
/** * Create new instance of <code>MongoEndpointNotification</code>. * @param dto data transfer object contain data that * assign on fields of new instance */ public MongoEndpointNotification(EndpointNotificationDto dto) { this.id = dto.getId(); this.endpointKeyHash = getArrayCopy(dto.getEndpointKeyHash()); this.notification = dto.getNotificationDto() != null ? new MongoNotification(dto.getNotificationDto()) : null; }