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