21
21
import com .fasterxml .jackson .dataformat .ion .EnumAsIonSymbolModule ;
22
22
import com .fasterxml .jackson .dataformat .ion .IonFactory ;
23
23
import com .fasterxml .jackson .dataformat .ion .IonObjectMapper ;
24
-
25
24
import com .amazon .ion .IonSystem ;
26
25
import com .amazon .ion .IonValue ;
26
+ import com .amazon .ion .system .IonSystemBuilder ;
27
27
28
28
/**
29
29
* Supports serializing Ion to POJO and back using the Jackson Ion framework.
@@ -52,11 +52,27 @@ public IonValueMapper(IonSystem ionSystem) {
52
52
this (ionSystem , null );
53
53
}
54
54
55
- // @since 2.18: needed for `copy()`
55
+ /**
56
+ * Needed for `copy()`
57
+ *
58
+ * @since 2.18
59
+ */
56
60
protected IonValueMapper (IonValueMapper src ) {
57
61
super (src );
58
62
}
59
63
64
+ /**
65
+ * Needed for some builders
66
+ *
67
+ * @since 2.18
68
+ */
69
+ protected IonValueMapper (IonFactory f , PropertyNamingStrategy strategy ) {
70
+ super (f );
71
+ this .registerModule (new IonValueModule ());
72
+ this .registerModule (new EnumAsIonSymbolModule ());
73
+ this .setPropertyNamingStrategy (strategy );
74
+ }
75
+
60
76
/**
61
77
* Constructor that provides an override on the default Constructor for the PropertyNamingStrategy.
62
78
*
@@ -66,19 +82,61 @@ protected IonValueMapper(IonValueMapper src) {
66
82
* {@link PropertyNamingStrategy}
67
83
*/
68
84
public IonValueMapper (IonSystem ionSystem , PropertyNamingStrategy strategy ) {
69
- super (new IonFactory (null , ionSystem ));
70
- this .registerModule (new IonValueModule ());
71
- this .registerModule (new EnumAsIonSymbolModule ());
72
- this .setPropertyNamingStrategy (strategy );
85
+ this (new IonFactory (null , ionSystem ), strategy );
73
86
}
74
87
75
88
/*
76
89
/**********************************************************************
77
90
/* Life-cycle, builders
91
+ /*
92
+ /* NOTE: must "override" (mask) all static methods from parent class
93
+ /* (most of which just call basic `builder()` or `builder(IonSystem)`
78
94
/**********************************************************************
79
95
*/
80
96
81
- // TODO: add overrides
97
+ public static Builder builder () {
98
+ return builder (IonSystemBuilder .standard ().build ());
99
+ }
100
+
101
+ public static Builder builder (IonSystem ionSystem ) {
102
+ return builder (ionSystem , null );
103
+ }
104
+
105
+ /**
106
+ * Canonical {@code builder()} method that most other methods
107
+ * ultimately call.
108
+ */
109
+ public static Builder builder (IonSystem ionSystem , PropertyNamingStrategy strategy ) {
110
+ return new Builder (new IonValueMapper (ionSystem , strategy ));
111
+ }
112
+
113
+ public static Builder builderForBinaryWriters () {
114
+ return builderForBinaryWriters (IonSystemBuilder .standard ().build ());
115
+ }
116
+
117
+ public static Builder builderForBinaryWriters (IonSystem ionSystem ) {
118
+ return builder (IonFactory .builderForBinaryWriters ()
119
+ .ionSystem (ionSystem )
120
+ .build ());
121
+ }
122
+
123
+ public static Builder builderForTextualWriters () {
124
+ return builderForTextualWriters (IonSystemBuilder .standard ().build ());
125
+ }
126
+
127
+ public static Builder builderForTextualWriters (IonSystem ionSystem ) {
128
+ return builder (IonFactory .builderForTextualWriters ()
129
+ .ionSystem (ionSystem )
130
+ .build ());
131
+ }
132
+
133
+ public static Builder builder (IonFactory streamFactory ) {
134
+ return builder (streamFactory , null );
135
+ }
136
+
137
+ public static Builder builder (IonFactory streamFactory , PropertyNamingStrategy strategy ) {
138
+ return new Builder (new IonValueMapper (streamFactory , strategy ));
139
+ }
82
140
83
141
/*
84
142
/**********************************************************************
0 commit comments