1

I have code block in java where I am trying to add customCodecProvider for mongo

(use 'clojure.reflect 'clojure.pprint)
(pprint (reflect org.bson.codecs.configuration.CodecRegistries))

{
  :bases #{java.lang.Object},
  :flags #{:public :final},
  :members
  #{{:name fromProviders,
  :return-type org.bson.codecs.configuration.CodecRegistry,
  :declaring-class org.bson.codecs.configuration.CodecRegistries,
  :parameter-types [org.bson.codecs.configuration.CodecProvider<>],
  :exception-types [],
  :flags #{:varargs :public :static}
}

java class has a method named fromProviders which accepts passing variable number ofCodecProvider it also has method with same name that takes List<CodecProviders> when I try to pass my CodecProvider to this method getting error

dev.core=> (org.bson.codecs.configuration.CodecRegistries/fromRegistries 
(CustomCodecProvider. ))

Execution error (IllegalArgumentException) at monger.core/eval25326 (form- 
init11680718377816350387.clj:1).
No matching method fromRegistries found taking 1 args

dev.core=> 

monger.core=> (org.bson.codecs.configuration.CodecRegistries/fromRegistries 
'((CustomCodecProvider. )))
#object[org.bson.internal.ProvidersCodecRegistry 0x505a9c0f 
"org.bson.internal.ProvidersCodecRegistry@2bff6ef5"]

How can I specify clojure to use the method that takes variable number of codecprovider instead of the one that uses List

arjunsv3691
  • 791
  • 6
  • 19

0 Answers0