|
1 |
| package com.agical.rdoc.core.impl; |
|
2 |
| |
|
3 |
| import java.util.HashMap; |
|
4 |
| import java.util.Map; |
|
5 |
| |
|
6 |
| import com.agical.rdoc.core.DocumentationContext; |
|
7 |
| |
|
8 |
| public class DocumentationContextWrapper { |
|
9 |
| private final Map context = new HashMap(); |
|
10 |
| private final DocumentationContext wrappedContext; |
|
11 |
| |
|
12 |
15
| public DocumentationContextWrapper(DocumentationContext wrappedContext) {
|
|
13 |
15
| this.wrappedContext = wrappedContext;
|
|
14 |
| } |
|
15 |
| |
|
16 |
7
| public Object get(String key) {
|
|
17 |
7
| Object value = context.get(key);
|
|
18 |
7
| if(value != null) {
|
|
19 |
6
| return value;
|
|
20 |
| } |
|
21 |
| else { |
|
22 |
1
| return wrappedContext.get(key);
|
|
23 |
| } |
|
24 |
| } |
|
25 |
| |
|
26 |
14
| public void put(String key, Object value) {
|
|
27 |
14
| context.put(key, value);
|
|
28 |
| } |
|
29 |
| |
|
30 |
1
| public boolean equals(Object obj) {
|
|
31 |
1
| if (obj instanceof DocumentationContextWrapper) {
|
|
32 |
1
| DocumentationContextWrapper other = (DocumentationContextWrapper) obj;
|
|
33 |
1
| return other.context.equals(this.context) && other.wrappedContext.equals(this.wrappedContext);
|
|
34 |
| } |
|
35 |
0
| return super.equals(obj);
|
|
36 |
| } |
|
37 |
| |
|
38 |
0
| public String toString() {
|
|
39 |
0
| return "context: "+context.toString() + "\nwrapped context: "+wrappedContext;
|
|
40 |
| } |
|
41 |
| } |