Using .get().get() twice is ugly, create a local variable.
Change-Id: I0c18c9138146c349c4c1c4003b5c53439893354e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
a4ac79f5adaceb503100ba3bb0a45edf7e2cc363)
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public SimulatedCreateSubscription(final String id, final Optional<File> notificationsFile) {
super(id);
public SimulatedCreateSubscription(final String id, final Optional<File> notificationsFile) {
super(id);
- Optional<Notifications> notifs;
+ final Optional<Notifications> notifs;
if (notificationsFile.isPresent()) {
notifs = Optional.of(loadNotifications(notificationsFile.get()));
if (notificationsFile.isPresent()) {
notifs = Optional.of(loadNotifications(notificationsFile.get()));
}
if (notifs.isPresent()) {
}
if (notifs.isPresent()) {
- Map<Notification, NetconfMessage> preparedMessages = Maps.newHashMapWithExpectedSize(
- notifs.get().getNotificationList().size());
- for (final Notification notification : notifs.get().getNotificationList()) {
+ final Collection<Notification> toCopy = notifs.get().getNotificationList();
+ final Map<Notification, NetconfMessage> preparedMessages = Maps.newHashMapWithExpectedSize(toCopy.size());
+ for (final Notification notification : toCopy) {
final NetconfMessage parsedNotification = parseNetconfNotification(notification.getContent());
preparedMessages.put(notification, parsedNotification);
}
final NetconfMessage parsedNotification = parseNetconfNotification(notification.getContent());
preparedMessages.put(notification, parsedNotification);
}
} else {
this.notifications = Collections.emptyMap();
}
} else {
this.notifications = Collections.emptyMap();
}
}
private static Notifications loadNotifications(final File file) {
}
private static Notifications loadNotifications(final File file) {