1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.index.treeview;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.apache.maven.index.ArtifactInfoFilter;
25 import org.apache.maven.index.Field;
26 import org.apache.maven.index.MAVEN;
27 import org.apache.maven.index.context.IndexingContext;
28
29 public class TreeViewRequest {
30 private final TreeNodeFactory factory;
31
32 private final String path;
33
34 private final ArtifactInfoFilter artifactInfoFilter;
35
36 private final Map<Field, String> fieldHints;
37
38 private final IndexingContext indexingContext;
39
40 public TreeViewRequest(final TreeNodeFactory factory, final String path, final IndexingContext ctx) {
41 this(factory, path, null, null, ctx);
42 }
43
44 public TreeViewRequest(
45 final TreeNodeFactory factory,
46 final String path,
47 final Map<Field, String> hints,
48 final ArtifactInfoFilter artifactInfoFilter,
49 final IndexingContext ctx) {
50 this.factory = factory;
51
52 this.path = path;
53
54 this.fieldHints = new HashMap<>();
55
56 if (hints != null && hints.size() != 0) {
57 this.fieldHints.putAll(hints);
58 }
59
60 this.artifactInfoFilter = artifactInfoFilter;
61
62 this.indexingContext = ctx;
63 }
64
65 public TreeNodeFactory getFactory() {
66 return factory;
67 }
68
69 public String getPath() {
70 return path;
71 }
72
73 public ArtifactInfoFilter getArtifactInfoFilter() {
74 return artifactInfoFilter;
75 }
76
77 public void addFieldHint(Field field, String hint) {
78 fieldHints.put(field, hint);
79 }
80
81 public void removeFieldHint(Field field) {
82 fieldHints.remove(field);
83 }
84
85 public boolean hasFieldHints() {
86 return fieldHints.size() > 0 && (hasFieldHint(MAVEN.GROUP_ID));
87 }
88
89 public boolean hasFieldHint(Field... fields) {
90 for (Field f : fields) {
91 if (!fieldHints.containsKey(f)) {
92 return false;
93 }
94 }
95
96 return true;
97 }
98
99 public String getFieldHint(Field field) {
100 return fieldHints.get(field);
101 }
102
103 public Map<Field, String> getFieldHints() {
104 return fieldHints;
105 }
106
107 public IndexingContext getIndexingContext() {
108 return indexingContext;
109 }
110 }