How to import and use an enum enclosed in an java interface?

1,748 views
Skip to first unread message

finbeu

unread,
Aug 2, 2011, 9:37:36 AM8/2/11
to clo...@googlegroups.com
Hello,

how do I have to use an enum in clojure that is enclosed in an java interface? I decomplied it in IDEA and I got something like that:

package com.api.test;

public interface Foo {
    .....
    .....
    static final enum BarType {
        public static final  ONE, public static final TWO, public static final THREE, public static final FOUR;
       
        ....
        ....
    }
}

How do I have to import and use that in clojure?

I need to call a java method with such an enum but I can't get it to work although I have already done lots of guesswork.

(:import (com.api.test Foo Foo.BarType)) ??????
(let [ test (.theMethod myObject BlaBlaType.ONE) ]) ????   

Thanks for your help in advance.

- Finn

Ken Wesson

unread,
Aug 2, 2011, 9:45:30 AM8/2/11
to clo...@googlegroups.com

Try (.theMethod myObject com.api.test.Foo$BarType/ONE) and let me know
how that works.

--
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

Meikel Brandmeyer (kotarak)

unread,
Aug 2, 2011, 9:47:27 AM8/2/11
to clo...@googlegroups.com
Hi,

and with import:

(import 'com.api.test.Foo$BarType)
(.theMethod myObject Foo$BarType/One)

Sincerely
Meikel

finbeu

unread,
Aug 2, 2011, 10:42:00 AM8/2/11
to clo...@googlegroups.com
Works! Ken, thx.


finbeu

unread,
Aug 2, 2011, 10:42:41 AM8/2/11
to clo...@googlegroups.com
This works also! thx a lot.

Ken Wesson

unread,
Aug 3, 2011, 3:46:44 AM8/3/11
to clo...@googlegroups.com
On Tue, Aug 2, 2011 at 10:42 AM, finbeu <info_...@t-online.de> wrote:
> Works! Ken, thx.

You're welcome.

Reply all
Reply to author
Forward
0 new messages