From a5e615d5726033cec37a1ebd3e00f880e765d16d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 29 Nov 2019 16:27:33 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Add=20nullability=20annotations?= =?utf8?q?=20to=20loaders=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/main/DebugLoaders.java | 8 ++++++-- src/main/java/net/pterodactylus/sone/main/DefaultLoaders.java | 8 ++++++-- src/main/java/net/pterodactylus/sone/main/Loaders.java | 8 +++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java b/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java index c42b056..2e18347 100644 --- a/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java +++ b/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java @@ -1,6 +1,7 @@ package net.pterodactylus.sone.main; import java.io.File; +import javax.annotation.Nonnull; import net.pterodactylus.sone.template.FilesystemTemplate; import net.pterodactylus.sone.web.pages.ReloadingPage; @@ -21,16 +22,19 @@ public class DebugLoaders implements Loaders { this.filesystemPath = filesystemPath; } + @Nonnull @Override - public Template loadTemplate(String path) { + public Template loadTemplate(@Nonnull String path) { return new FilesystemTemplate(new File(filesystemPath, path).getAbsolutePath()); } + @Nonnull @Override - public Page loadStaticPage(String basePath, String prefix, String mimeType) { + public Page loadStaticPage(@Nonnull String basePath, @Nonnull String prefix, @Nonnull String mimeType) { return new ReloadingPage<>(basePath, new File(filesystemPath, prefix).getAbsolutePath(), mimeType); } + @Nonnull @Override public TemplateProvider getTemplateProvider() { return new FilesystemTemplateProvider(new File(filesystemPath, "/templates/").getAbsolutePath()); diff --git a/src/main/java/net/pterodactylus/sone/main/DefaultLoaders.java b/src/main/java/net/pterodactylus/sone/main/DefaultLoaders.java index 72d8d19..8e02573 100644 --- a/src/main/java/net/pterodactylus/sone/main/DefaultLoaders.java +++ b/src/main/java/net/pterodactylus/sone/main/DefaultLoaders.java @@ -6,6 +6,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.UnsupportedEncodingException; +import javax.annotation.Nonnull; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.io.Closer; @@ -21,8 +22,9 @@ import net.pterodactylus.util.web.StaticPage; */ public class DefaultLoaders implements Loaders { + @Nonnull @Override - public Template loadTemplate(String path) { + public Template loadTemplate(@Nonnull String path) { InputStream templateInputStream = null; Reader reader = null; try { @@ -37,12 +39,14 @@ public class DefaultLoaders implements Loaders { } } + @Nonnull @Override - public Page loadStaticPage(String pathPrefix, String basePath, String mimeType) { + public Page loadStaticPage(@Nonnull String pathPrefix, @Nonnull String basePath, @Nonnull String mimeType) { return new StaticPage(pathPrefix, basePath, mimeType) { }; } + @Nonnull @Override public TemplateProvider getTemplateProvider() { return new ClassPathTemplateProvider(WebInterface.class, "/templates/"); diff --git a/src/main/java/net/pterodactylus/sone/main/Loaders.java b/src/main/java/net/pterodactylus/sone/main/Loaders.java index 8ee5132..b07118b 100644 --- a/src/main/java/net/pterodactylus/sone/main/Loaders.java +++ b/src/main/java/net/pterodactylus/sone/main/Loaders.java @@ -1,5 +1,7 @@ package net.pterodactylus.sone.main; +import javax.annotation.Nonnull; + import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateProvider; import net.pterodactylus.util.web.Page; @@ -13,8 +15,8 @@ import com.google.inject.ImplementedBy; @ImplementedBy(DefaultLoaders.class) public interface Loaders { - Template loadTemplate(String path); - Page loadStaticPage(String basePath, String prefix, String mimeType); - TemplateProvider getTemplateProvider(); + @Nonnull Template loadTemplate(@Nonnull String path); + @Nonnull Page loadStaticPage(@Nonnull String basePath, @Nonnull String prefix, @Nonnull String mimeType); + @Nonnull TemplateProvider getTemplateProvider(); } -- 2.7.4