Anand Nalya
Anand Nalya

Reputation: 751

Compiles in java but not in scala

Why does the following statement compiles in java but fails to compile in scala

new ClientConfig.Builder("http://localhost:9200").multiThreaded(true).build()

Scala IDE says "value multiThreaded is not a member of io.searchbox.client.config.ClientConfig.Builder" The class in question can be found here

Upvotes: 1

Views: 102

Answers (1)

DNA
DNA

Reputation: 42597

This simple example works:

// Java
public class JavaClass
{
    public static class Builder
    {
        public Builder(String serverUri)
        {
        }

        public Builder multiThreaded(boolean isMultiThreaded)
        {
            return this;
        }

        public Builder discoveryEnabled(boolean isDiscoveryEnabled)
        {
            return this;
        }

        public String build()
        {
            return "BUILD";
        }
    }
}

Scala client (an an Eclipse Scala IDE worksheet)

object ScalaClient {
  new JavaClass.Builder("http://test").multiThreaded(true).discoveryEnabled(false).build()
}

Try cleaning and rebuilding the project - when I was writing this simple example I got similar errors to you, which vanished when I cleaned the project.

Upvotes: 2

Related Questions