X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FAbstractSoneCommand.java;h=23f63a330fd32cf86da62c133c9d2098c1271e9d;hp=98a43ab95734e851b647d6d862f4aa2ff713f63d;hb=5ef06b540267732918fa2119c8d9536ef81b0dfd;hpb=18423dd893c8d4f1ef7d3a82ae229f5544b7616e
diff --git a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
index 98a43ab..23f63a3 100644
--- a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
+++ b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
@@ -40,8 +40,6 @@ import com.google.common.base.Optional;
/**
* Abstract base implementation of a {@link Command} with Sone-related helper
* methods.
- *
- * @author David âBombeâ Roden
*/
public abstract class AbstractSoneCommand extends AbstractCommand {
@@ -161,11 +159,11 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
if (mandatory && (soneId == null)) {
throw new FcpException("Could not load Sone ID from â" + parameterName + "â.");
}
- Optional sone = core.getSone(soneId);
- if ((mandatory && !sone.isPresent()) || (sone.isPresent() && localOnly && !sone.get().isLocal())) {
+ Sone sone = core.getSone(soneId);
+ if ((mandatory && (sone == null)) || ((sone != null) && localOnly && !sone.isLocal())) {
throw new FcpException("Could not load Sone from â" + soneId + "â.");
}
- return sone;
+ return Optional.fromNullable(sone);
}
/**
@@ -184,11 +182,11 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
protected Post getPost(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
try {
String postId = simpleFieldSet.getString(parameterName);
- Optional post = core.getPost(postId);
- if (!post.isPresent()) {
+ Post post = core.getPost(postId);
+ if (post == null) {
throw new FcpException("Could not load post from â" + postId + "â.");
}
- return post.get();
+ return post;
} catch (FSParseException fspe1) {
throw new FcpException("Could not post ID from â" + parameterName + "â.", fspe1);
}
@@ -210,11 +208,11 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
protected PostReply getReply(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
try {
String replyId = simpleFieldSet.getString(parameterName);
- Optional reply = core.getPostReply(replyId);
- if (!reply.isPresent()) {
+ PostReply reply = core.getPostReply(replyId);
+ if (reply == null) {
throw new FcpException("Could not load reply from â" + replyId + "â.");
}
- return reply.get();
+ return reply;
} catch (FSParseException fspe1) {
throw new FcpException("Could not reply ID from â" + parameterName + "â.", fspe1);
}