X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FIdentityAccessor.java;h=5b229dd9f7eff9d68ae0f64612aa34eb1dfe06f3;hp=4fbe74cf9e1ebff9a95f7c68b434a9bc09ac34a7;hb=HEAD;hpb=5723a2bb28376b0972a63bae2124846116cf6ca5 diff --git a/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java b/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java index 4fbe74c..5b229dd 100644 --- a/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityAccessor.java - Copyright © 2010–2012 David Roden + * Sone - IdentityAccessor.java - Copyright © 2010–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 @@ -19,6 +19,9 @@ package net.pterodactylus.sone.template; import java.util.Set; +import javax.inject.Inject; +import javax.inject.Singleton; + import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; @@ -29,9 +32,8 @@ import net.pterodactylus.util.template.TemplateContext; /** * {@link Accessor} implementation that adds a “uniqueNickname” member to an * {@link Identity}. - * - * @author David ‘Bombe’ Roden */ +@Singleton public class IdentityAccessor extends ReflectionAccessor { /** The core. */ @@ -43,6 +45,7 @@ public class IdentityAccessor extends ReflectionAccessor { * @param core * The core */ + @Inject public IdentityAccessor(Core core) { this.core = core; } @@ -55,9 +58,8 @@ public class IdentityAccessor extends ReflectionAccessor { Identity identity = (Identity) object; if ("uniqueNickname".equals(member)) { int minLength = -1; - boolean found = false; - Set ownIdentities = null; - ownIdentities = core.getIdentityManager().getAllOwnIdentities(); + boolean found; + Set ownIdentities = core.getIdentityManager().getAllOwnIdentities(); do { boolean unique = true; String abbreviatedWantedNickname = getAbbreviatedNickname(identity, ++minLength);