简体   繁体   中英

How to write the following class in Clojure?

I want to write the following in Clojure, but I can't figure it out for the life of me:

new TouchCommand() {

    @Override
    public void itemTouched(TouchMenuItem selectedItem) {
    }

I tried:

(reify com.vaadin.touchkit.TouchMenu$TouchCommand 
  (itemTouched [^com.vaadin.touchkit.TouchMenu$TouchMenuItem item]))

but it returns:

java.lang.IllegalArgumentException: Can't define method not in interfaces: itemTouched 

even though "itemTouched" does exist in the interface. Can anyone help?

I haven't done extensive Java interop with Clojure so this might be wrong, but how about

(proxy [TouchCommand] []
  (itemTouched [selectedItem]
               (.. (getParent)
                   (navigateTo
                     (UiBasics.)))))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM