Access to a Java static inner class with Clojure

I'm trying access to a static inner class method, but I can't find the right way.

I need to write this java code in Clojure:

SessionProperties sessionProperties = SessionProperties.Builder().mediaMode(MediaMode.ROUTED).build();

My code is:

(:import [com.opentok OpenTok MediaMode SessionProperties SessionProperties$Builder]))

(def sessionProperties (.build (.mediaMode SessionProperties$Builder MediaMode/ROUTED))

And this is the error:

java.lang.IllegalArgumentException: No matching method found: mediaMode for class java.lang.Class

I'm using the opentok Java library and I don't understand how to access to mediaMode method.

Answers


Your Java code does not work. To fix the remedy, add the new keyword between = and SessionProperties.Builder(). It should be:

SessionProperties sessionProperties = new SessionProperties.Builder()
  .mediaMode(MediaMode.ROUTED)
  .build();

You can do this in Clojure as follows.

user> (import '(com.opentok SessionProperties$Builder MediaMode))
com.opentok.MediaMode

user> (def session-properties (.. (SessionProperties$Builder.)
                                  (mediaMode MediaMode/ROUTED)
                                  build))
#'user/session-properties

user> session-properties
#<SessionProperties com.opentok.SessionProperties@54fc58ee>

Need Your Help

Autowiring exception when using multiple context loaders in JUnit

spring maven junit4 maven-surefire-plugin

I have created 2 classes A,B for JUnit, each has its own ContextLoaders for loading the application context. Now when I run each of these classes independently the JUnit test run fine.

Angular custom filter not updating ng-repeat

javascript angularjs angularjs-ng-repeat angularjs-filter

There are alot of questions on here about ng-repeat and custom filters but none of them address the problem I am facing.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.