Merge branch 'next' into feature/album-and-image-links
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneParser.java
index ae1e2a5..9122852 100644 (file)
@@ -29,6 +29,7 @@ import net.pterodactylus.sone.database.SoneBuilder;
 import net.pterodactylus.util.xml.SimpleXML;
 import net.pterodactylus.util.xml.XML;
 
+import com.google.common.base.Optional;
 import org.w3c.dom.Document;
 
 /**
@@ -266,10 +267,10 @@ public class SoneParser {
                                        logger.log(Level.WARNING, String.format("Downloaded Sone %s contains invalid album!", sone));
                                        return null;
                                }
-                               Album parent = null;
+                               Optional<Album> parent = Optional.absent();
                                if (parentId != null) {
                                        parent = core.getAlbum(parentId);
-                                       if (parent == null) {
+                                       if (!parent.isPresent()) {
                                                logger.log(Level.WARNING, String.format("Downloaded Sone %s has album with invalid parent!", sone));
                                                return null;
                                        }
@@ -282,8 +283,8 @@ public class SoneParser {
                                                .setTitle(title)
                                                .setDescription(description)
                                                .update();
-                               if (parent != null) {
-                                       parent.addAlbum(album);
+                               if (parent.isPresent()) {
+                                       parent.get().addAlbum(album);
                                } else {
                                        topLevelAlbums.add(album);
                                }