/*
- * Sone - Matchers.java - Copyright © 2013–2016 David Roden
+ * Sone - Matchers.java - Copyright © 2013–2020 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import java.io.IOException;
import java.io.InputStream;
+import javax.annotation.*;
+
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Post;
};
}
- public static Matcher<Post> isPost(String postId, long time,
- String text, Optional<String> recipient) {
+ public static Matcher<Post> isPost(String postId, long time, String text, @Nullable String recipient) {
return new PostMatcher(postId, time, text, recipient);
}
private final String postId;
private final long time;
private final String text;
- private final Optional<String> recipient;
+ @Nullable
+ private final String recipient;
- private PostMatcher(String postId, long time, String text,
- Optional<String> recipient) {
+ private PostMatcher(String postId, long time, String text, @Nullable String recipient) {
this.postId = postId;
this.time = time;
this.text = text;
.appendValue(text);
return false;
}
- if (recipient.isPresent()) {
+ if (recipient != null) {
if (!post.getRecipientId().isPresent()) {
mismatchDescription.appendText(
"Recipient not present");
return false;
}
- if (!post.getRecipientId().get().equals(recipient.get())) {
+ if (!post.getRecipientId().get().equals(recipient)) {
mismatchDescription.appendText("Recipient is not ")
- .appendValue(recipient.get());
+ .appendValue(recipient);
return false;
}
} else {
.appendValue(postId);
description.appendText(", created at @").appendValue(time);
description.appendText(", text ").appendValue(text);
- if (recipient.isPresent()) {
+ if (recipient != null) {
description.appendText(", directed at ")
- .appendValue(recipient.get());
+ .appendValue(recipient);
}
}