1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.settings4j.objectresolver;
19
20 import org.settings4j.ContentResolver;
21 import org.settings4j.Filter;
22 import org.settings4j.ObjectResolver;
23
24
25
26
27
28
29 public class FilteredObjectResolverWrapper implements ObjectResolver {
30
31 private final ObjectResolver targetObjectResolver;
32 private final Filter filter;
33
34
35
36
37
38
39 public FilteredObjectResolverWrapper(final ObjectResolver targetObjectResolver, final Filter filter) {
40 super();
41 if (targetObjectResolver == null) {
42 throw new IllegalArgumentException("FilteredConnectorWrapper needs a ObjectResolver Object");
43 }
44 if (filter == null) {
45 throw new IllegalArgumentException("FilteredConnectorWrapper needs a Filter Object");
46 }
47 this.targetObjectResolver = targetObjectResolver;
48 this.filter = filter;
49 }
50
51
52 public void addObjectResolver(final ObjectResolver objectResolver) {
53 this.targetObjectResolver.addObjectResolver(objectResolver);
54 }
55
56
57 public Object getObject(final String key, final ContentResolver contentResolver) {
58 if (!this.filter.isValid(key)) {
59 return null;
60 }
61 return this.targetObjectResolver.getObject(key, contentResolver);
62 }
63 }