1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jadira.bindings.core.general.binding;
17
18 import org.jadira.bindings.core.api.Binding;
19 import org.jadira.bindings.core.api.FromUnmarshaller;
20 import org.jadira.bindings.core.api.ToMarshaller;
21
22
23
24
25
26
27 public class CompositeBinding<S, T> implements Binding<S, T> {
28
29 private final ToMarshaller<S, T> marshal;
30
31 private final FromUnmarshaller<S, T> unmarshal;
32
33
34
35
36
37
38 public CompositeBinding(ToMarshaller<S, T> marshal, FromUnmarshaller<S, T> unmarshal) {
39
40 if (unmarshal == null) {
41 throw new IllegalStateException("Unmarshaller may not be null");
42 }
43 if (marshal == null) {
44 throw new IllegalStateException("Marshaller may not be null");
45 }
46
47 this.unmarshal = unmarshal;
48 this.marshal = marshal;
49 }
50
51
52
53
54
55 public T marshal(S object) {
56 return marshal.marshal(object);
57 }
58
59
60
61
62
63 public S unmarshal(T inputString) {
64 return unmarshal.unmarshal(inputString);
65 }
66
67
68
69
70
71 public Class<S> getBoundClass() {
72 return unmarshal.getBoundClass();
73 }
74
75
76
77
78
79 public Class<T> getTargetClass() {
80 return unmarshal.getTargetClass();
81 }
82 }