1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transformer.types; |
12 | |
|
13 | |
import org.mule.api.transformer.DataType; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
class ImmutableDataType<T> implements DataType<T> |
19 | |
{ |
20 | |
private DataType<T> theDataType; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public ImmutableDataType(DataType<T> theDataType) |
26 | 0 | { |
27 | 0 | this.theDataType = theDataType; |
28 | 0 | } |
29 | |
|
30 | |
|
31 | |
|
32 | |
public Class<?> getType() |
33 | |
{ |
34 | 0 | return theDataType.getType(); |
35 | |
} |
36 | |
|
37 | |
public String getMimeType() |
38 | |
{ |
39 | 0 | return theDataType.getMimeType(); |
40 | |
} |
41 | |
|
42 | |
public String getEncoding() |
43 | |
{ |
44 | 0 | return theDataType.getEncoding(); |
45 | |
} |
46 | |
|
47 | |
public boolean isCompatibleWith(DataType dataType) |
48 | |
{ |
49 | 0 | return theDataType.isCompatibleWith(dataType); |
50 | |
} |
51 | |
|
52 | |
public DataType cloneDataType() |
53 | |
{ |
54 | 0 | return theDataType.cloneDataType(); |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
public String toString() |
59 | |
{ |
60 | 0 | return theDataType.toString(); |
61 | |
} |
62 | |
|
63 | |
|
64 | |
public void setEncoding(String encoding) |
65 | |
{ |
66 | 0 | attemptToMutate(); |
67 | 0 | } |
68 | |
|
69 | |
public void setMimeType(String mimeType) |
70 | |
{ |
71 | 0 | attemptToMutate(); |
72 | 0 | } |
73 | |
|
74 | |
protected DataType<T> getWrappedDataType() |
75 | |
{ |
76 | 0 | if (theDataType instanceof ImmutableDataType) |
77 | |
{ |
78 | 0 | return ((ImmutableDataType)theDataType).getWrappedDataType(); |
79 | |
} |
80 | |
else |
81 | |
{ |
82 | 0 | return theDataType; |
83 | |
} |
84 | |
} |
85 | |
|
86 | |
private void attemptToMutate() |
87 | |
{ |
88 | 0 | throw new UnsupportedOperationException("Attempt to change immutable DataType " + theDataType); |
89 | |
} |
90 | |
|
91 | |
@Override |
92 | |
public int hashCode() |
93 | |
{ |
94 | 0 | return theDataType.hashCode(); |
95 | |
} |
96 | |
} |