1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.symboltable;
5
6 import net.sourceforge.pmd.util.UnaryFunction;
7
8 import java.util.HashMap;
9 import java.util.List;
10 import java.util.Map;
11
12 public class VariableUsageFinderFunction implements UnaryFunction {
13 private Map results = new HashMap();
14 private Map decls;
15 private boolean lookingForUsed;
16
17 public VariableUsageFinderFunction(Map decls, boolean lookingForUsed) {
18 this.decls = decls;
19 this.lookingForUsed = lookingForUsed;
20 }
21
22 public void applyTo(Object o) {
23 NameDeclaration decl = (NameDeclaration) o;
24 List usages = (List) decls.get(decl);
25 if (!usages.isEmpty()) {
26 if (lookingForUsed) {
27 results.put(decl, usages);
28 }
29 } else {
30 if (!lookingForUsed) {
31 results.put(decl, usages);
32 }
33 }
34 }
35
36 public Map getUsed() {
37 return results;
38 }
39 }
This page was automatically generated by Maven