From: David ‘Bombe’ Roden Date: Fri, 29 Nov 2019 15:27:33 +0000 (+0100) Subject: 🎨 Add nullability annotations to loaders interface X-Git-Tag: v81^2~15^2~6 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a5e615d5726033cec37a1ebd3e00f880e765d16d;p=Sone.git 🎨 Add nullability annotations to loaders interface --- 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(); }