Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure accessing static inner class builder expecting var but mapped to class error on build

Tags:

In Clojure I want to interop to use:

JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
                    .Builder("http://localhost:9200")
                    .build());

So I wrote some code like so:

 (:import (io.searchbox.client JestClientFactory)
          (io.searchbox.client.config HttpClientConfig$Builder))

 (let [factory (JestClientFactory.)
       http-client-config (-> (HttpClientConfig$Builder "http://localhost:9200")
                           (.build))])

But I am getting the following error when building the jar

Expecting var, but HttpClientConfig$Builder is mapped to class io.searchbox.client.config.HttpClientConfig$Builder

Any help would be great.

like image 967
perkss Avatar asked Jul 21 '19 08:07

perkss


1 Answers

You lack the . behind HttpClientConfig$Builder. Your code does a static call on a class basically. You need the new from your example.

(-> (HttpClientConfig$Builder. "http://localhost:9200") ; note the `.`
    (.build))
like image 143
cfrick Avatar answered Oct 18 '22 21:10

cfrick