From 16b7ecd68873178d79b81023fc702d61d7696e13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 25 Jun 2016 22:24:34 +0200 Subject: [PATCH] Clean up parser interface --- src/main/java/net/pterodactylus/sone/text/Parser.java | 5 ++++- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/text/Parser.java b/src/main/java/net/pterodactylus/sone/text/Parser.java index 531efa7..ca26a79 100644 --- a/src/main/java/net/pterodactylus/sone/text/Parser.java +++ b/src/main/java/net/pterodactylus/sone/text/Parser.java @@ -19,6 +19,8 @@ package net.pterodactylus.sone.text; import java.io.IOException; import java.io.Reader; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Interface for parsers that can create {@link Part}s from a text source @@ -39,6 +41,7 @@ public interface Parser { * The text source * @return The parsed parts */ - public Iterable parse(C context, String source); + @Nonnull + Iterable parse(@Nullable C context, @Nonnull String source); } diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 18dd53f..ae299e1 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -28,6 +28,9 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.impl.IdOnlySone; @@ -117,8 +120,9 @@ public class SoneTextParser implements Parser { /** * {@inheritDoc} */ + @Nonnull @Override - public Iterable parse(SoneTextParserContext context, String source) { + public Iterable parse(@Nullable SoneTextParserContext context, @Nonnull String source) { PartContainer parts = new PartContainer(); BufferedReader bufferedReader = new BufferedReader(new StringReader(source)); try { -- 2.7.4