On Tue, Feb 22, 2011 at 11:38 PM, Kasim <ktu...@gmail.com> wrote:
> Hi Hackers,
> I am trying to import and use following Enum class from Clojure:
> http://build.xuggle.com/view/Stable/job/xuggler_jdk5_stable/javadoc/java/api/com/xuggle/xuggler/IContainer.Type.html
>
> Basically, I need it so that I can feed it to a Java method that requires
> it. I'd appreciate any idea or help.

If the enum is a top level class: com.example.package.EnumClass and
com.example.package.EnumClass/EnumConstant. If the enum is nested in
Foo, com.example.package.Foo$EnumClass and
com.example.package.Foo$EnumClass/EnumConstant.

The enum class can be imported like any other class. If you want a
shorthand for the constants, like foo for EnumClass/FOO, you can do
something like this

(ns quux
  (import [com.example.package EnumClass]))

(def foo EnumClass/FOO)

...

(do-something-with foo)

...

(.javaMethod some-object ^String "boo!" (int 42) ^EnumClass foo)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to