我正在尝试使用hapi fhir从clojure创建一个dstu2客户端。我使用https://github.com/jamesagnew/hapi-fhir/blob/master/examples/src/main/java/example/GenericClientExample.java作为模板
但是我不能执行
ctx.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING);
in clojure我做的事情如下:
(def fhir-context (. FhirContext forDstu2))
=> #'emrspp.fhir-resources/fhir-context
(def opts PerformanceOptionsEnum/DEFERRED_MODEL_SCANNING)
=> #'emrspp.fhir-resources/opts 但是下面的But失败了:
(.setPerformanceOptions fhir-context opts)
=>
CompilerException java.lang.IllegalArgumentException: No matching method found: setPerformanceOptions for class ca.uhn.fhir.context.FhirContextclojure反射提供了以下功能:
(pprint (filter #(= "setPerformanceOptions" (str (:name %))) (:members (r/reflect fhir-context))))
=>
~
({:name setPerformanceOptions,
:return-type void,
:declaring-class ca.uhn.fhir.context.FhirContext,
:parameter-types [ca.uhn.fhir.context.PerformanceOptionsEnum<>],
:exception-types [],
:flags #{:varargs :public}}
{:name setPerformanceOptions,
:return-type void,
:declaring-class ca.uhn.fhir.context.FhirContext,
:parameter-types [java.util.Collection],
:exception-types [],
:flags #{:public}})
nilimports部分为:
(:import [org.hl7.fhir.instance.model.api IBaseOperationOutcome IBaseResource ]
7 [ca.uhn.fhir.context FhirContext PerformanceOptionsEnum]
8 [ca.uhn.fhir.model.base.resource BaseOperationOutcome ]
9 [ca.uhn.fhir.model.dstu2.resource Bundle
10 Conformance Observation
11 OperationOutcome
12 Organization Parameters
13 Patient Provenance]
14 [ca.uhn.fhir.model.dstu2.valueset AdministrativeGenderEnum IssueSeverityEnum]
15 [ca.uhn.fhir.model.primitive DateDt IdDt InstantDt]
16 [ca.uhn.fhir.rest.api MethodOutcome SummaryEnum ]
17 [ca.uhn.fhir.rest.client IGenericClient ServerValidationModeEnum interceptor.LoggingInterceptor ]
18 [ca.uhn.fhir.rest.method.SearchStyleEnum ]
19 [ca.uhn.fhir.rest.param.DateRangeParam ]
20 [ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException ]
21 )with no :除了pprint和reflection之外,需要
关于看似存在但实际执行的方法setPerformanceOptions会发生什么情况?
发布于 2017-03-13 05:46:55
几个小时后我就想通了。我仔细查看了名称空间:http://hapifhir.io/apidocs/ca/uhn/fhir/context/FhirContext.html揭示了传递的参数需要是一个java集合,因此
(.setPerformanceOptions fhir-context opts)必须更改为
(.setPerformanceOptions fhir-context (java.util.ArrayList. [opts]))或更简单
(.setPerformanceOptions fhir-context [opts] )https://stackoverflow.com/questions/42750589
复制相似问题