X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FAlbumAccessor.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FAlbumAccessor.java;h=13b4d65c766b6a6828c9ce36636f9e8446877374;hb=800a866c8d935a386b4fb7182f4647950bb86791;hp=fcd7a70d5fc17f03707cc7102cc2c830c96ccf43;hpb=abf62ec9f00f472152351e642e3e73a0743bae0e;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java index fcd7a70..13b4d65 100644 --- a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java @@ -18,9 +18,7 @@ package net.pterodactylus.sone.template; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import net.pterodactylus.sone.data.Album; import net.pterodactylus.util.template.Accessor; @@ -43,36 +41,66 @@ public class AlbumAccessor extends ReflectionAccessor { public Object get(TemplateContext templateContext, Object object, String member) { Album album = (Album) object; if ("backlinks".equals(member)) { - List> backlinks = new ArrayList>(); + List backlinks = new ArrayList(); Album currentAlbum = album; while (!currentAlbum.equals(album.getSone().getRootAlbum())) { - backlinks.add(0, createLink("imageBrowser.html?album=" + currentAlbum.getId(), currentAlbum.getTitle())); + backlinks.add(0, new Link("imageBrowser.html?album=" + currentAlbum.getId(), currentAlbum.getTitle())); currentAlbum = currentAlbum.getParent(); } - backlinks.add(0, createLink("imageBrowser.html?sone=" + album.getSone().getId(), SoneAccessor.getNiceName(album.getSone()))); + backlinks.add(0, new Link("imageBrowser.html?sone=" + album.getSone().getId(), SoneAccessor.getNiceName(album.getSone()))); return backlinks; } return super.get(templateContext, object, member); } - // - // PRIVATE METHODS - // - /** - * Creates a map containing mappings for “target” and “link.” + * Container for links. * - * @param target - * The target to link to - * @param name - * The name of the link - * @return The created map containing the mappings + * @author David ‘Bombe’ Roden */ - private static Map createLink(String target, String name) { - Map link = new HashMap(); - link.put("target", target); - link.put("name", name); - return link; + private static class Link { + + /** The target of the link. */ + private final String target; + + /** The name of the link. */ + private final String name; + + /** + * Creates a new link. + * + * @param target + * The target of the link + * @param name + * The name of the link + */ + private Link(String target, String name) { + this.target = target; + this.name = name; + } + + // + // ACCESSORS + // + + /** + * Returns the target of the link. + * + * @return The target of the link + */ + public String getTarget() { + return target; + } + + /** + * Returns the name of the link. + * + * @return The name of the link + */ + public String getName() { + return name; + } + } }