1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.p2elv2;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25
26
27
28
29 public class PVarValue<VALUE_TYPE extends Serializable> implements Serializable {
30
31 protected VALUE_TYPE value;
32 protected transient Map<PProcessorType, List<PProcessor>> processors = new HashMap<PProcessorType, List<PProcessor>>();
33
34 public PVarValue(VALUE_TYPE value) {
35 this(value, null, null);
36 }
37
38 public PVarValue(VALUE_TYPE value, PProcessor preProcessor, PProcessor postProcessor) {
39 for (PProcessorType procType : PProcessorType.values()) processors.put(procType, new ArrayList<PProcessor>());
40
41 this.value = value;
42
43 if (preProcessor != null) getProcessors(PProcessorType.PRE).add(preProcessor);
44 if (postProcessor != null) getProcessors(PProcessorType.POST).add(postProcessor);
45 }
46
47 public Object getVTLModel() {
48 return value;
49 }
50
51 public List<PProcessor> getProcessors(PProcessorType procType) {
52 if (processors == null) processors = new HashMap<PProcessorType, List<PProcessor>>();
53 List<PProcessor> result = processors.get(procType);
54 if (result == null) {
55 result = new ArrayList<PProcessor>();
56 processors.put(procType, result);
57 }
58 return result;
59 }
60
61 public String toString() {
62 return value.toString();
63 }
64
65 @Override
66 public int hashCode() {
67 final int prime = 31;
68 int result = 1;
69 result = prime * result + ((value == null) ? 0 : value.hashCode());
70 return result;
71 }
72
73 @Override
74 public boolean equals(Object obj) {
75 if (this == obj)
76 return true;
77 if (obj == null)
78 return false;
79 if (getClass() != obj.getClass())
80 return false;
81 final PVarValue other = (PVarValue) obj;
82 if (value == null) {
83 if (other.value != null)
84 return false;
85 } else if (!value.equals(other.value))
86 return false;
87 return true;
88 }
89 }
90