2 * WoTNS - IdentityTargets.java - Copyright © 2011 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.wotns.main;
20 import java.util.Collections;
21 import java.util.HashMap;
22 import java.util.Iterator;
24 import java.util.Map.Entry;
26 import net.pterodactylus.wotns.freenet.wot.Identity;
31 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
33 public class IdentityTargets implements Iterable<Entry<String, String>> {
35 private final Identity identity;
37 private final Map<String, String> targets = new HashMap<String, String>();
39 public IdentityTargets(Identity identity) {
40 this.identity = identity;
43 public Map<String, String> getTargets() {
45 return Collections.unmodifiableMap(targets);
48 public String getTarget(String name) {
50 return targets.get(name);
57 private void scanForTargets() {
58 synchronized (targets) {
59 for (Entry<String, String> property : identity.getProperties().entrySet()) {
60 if (property.getKey().startsWith("tns.")) {
61 targets.put(property.getKey().substring(4), property.getValue());
75 public Iterator<Entry<String, String>> iterator() {
76 return targets.entrySet().iterator();