@@ -25,10 +25,7 @@ import org.bson.ByteBufNIO
25
25
import org.bson.codecs.Codec
26
26
import org.bson.codecs.DecoderContext
27
27
import org.bson.codecs.EncoderContext
28
- import org.bson.codecs.IntegerCodec
29
28
import org.bson.codecs.MinKeyCodec
30
- import org.bson.codecs.Parameterizable
31
- import org.bson.codecs.ValueCodecProvider
32
29
import org.bson.codecs.configuration.CodecConfigurationException
33
30
import org.bson.codecs.configuration.CodecProvider
34
31
import org.bson.codecs.configuration.CodecRegistry
@@ -38,12 +35,9 @@ import org.bson.types.MaxKey
38
35
import org.bson.types.MinKey
39
36
import spock.lang.Specification
40
37
41
- import java.lang.reflect.Type
42
38
import java.nio.ByteBuffer
43
39
44
40
import static java.util.Arrays.asList
45
- import static org.bson.codecs.ContainerCodecHelper.getCodec
46
- import static org.bson.codecs.configuration.CodecRegistries.fromCodecs
47
41
48
42
class ProvidersCodecRegistrySpecification extends Specification {
49
43
@@ -169,93 +163,6 @@ class ProvidersCodecRegistrySpecification extends Specification {
169
163
expect :
170
164
((SimpleCodec ) provider. get(Simple , registry)). registry. is(registry)
171
165
}
172
-
173
- def ' should parameterize codec' () {
174
- given :
175
- def registry = new ProvidersCodecRegistry ([fromCodecs(new CollectionCodec ()), new ValueCodecProvider ()])
176
-
177
- when :
178
- def codec = registry. get(Collection , [Integer ])
179
-
180
- then :
181
- codec instanceof ParameterizedCollectionCodec
182
- (codec as ParameterizedCollectionCodec ). getCodec() instanceof IntegerCodec
183
-
184
- when :
185
- def secondCodec = registry. get(Collection , [Integer ])
186
-
187
- then :
188
- codec == secondCodec
189
- }
190
-
191
- def ' should parameterize codec with cycles' () {
192
- given :
193
- def registry = new ProvidersCodecRegistry ([fromCodecs(new CollectionCodec ()), new ValueCodecProvider ()])
194
-
195
- when :
196
- def codec = registry. get(Collection , [Holder . getField(' c' ). getGenericType()])
197
-
198
- then :
199
- codec instanceof ParameterizedCollectionCodec
200
- (codec as ParameterizedCollectionCodec ). getCodec() instanceof LazyCodec
201
-
202
- when :
203
- def secondCodec = registry. get(Collection , [Holder . getField(' c' ). getGenericType()])
204
-
205
- then :
206
- codec == secondCodec
207
- }
208
- }
209
-
210
- class CollectionCodec implements Codec<Collection<?> > , Parameterizable {
211
-
212
- @Override
213
- Collection<?> decode (BsonReader reader , DecoderContext decoderContext ) {
214
- throw new UnsupportedOperationException ()
215
- }
216
-
217
- @Override
218
- void encode (BsonWriter writer , Collection<?> value , EncoderContext encoderContext ) {
219
- throw new UnsupportedOperationException ()
220
- }
221
-
222
- @Override
223
- Class<Collection<?> > getEncoderClass () {
224
- Collection
225
- }
226
-
227
- @Override
228
- Codec<?> parameterize (CodecRegistry codecRegistry , List<Type > types ) {
229
- new ParameterizedCollectionCodec (getCodec(codecRegistry, types. get(0 )))
230
- }
231
- }
232
-
233
- class ParameterizedCollectionCodec <T> implements Codec<Collection<T> > {
234
-
235
- private final Codec<T> codec
236
-
237
- ParameterizedCollectionCodec (Codec<T> codec ) {
238
- this . codec = codec
239
- }
240
-
241
- Codec<T> getCodec () {
242
- codec
243
- }
244
-
245
- @Override
246
- Collection<T> decode (BsonReader reader , DecoderContext decoderContext ) {
247
- throw new UnsupportedOperationException ()
248
- }
249
-
250
- @Override
251
- void encode (BsonWriter writer , Collection<T> value , EncoderContext encoderContext ) {
252
- throw new UnsupportedOperationException ()
253
- }
254
-
255
- @Override
256
- Class<Collection<T> > getEncoderClass () {
257
- Collection
258
- }
259
166
}
260
167
261
168
class SingleCodecProvider implements CodecProvider {
0 commit comments