java - Make a class that extends a class with overriding in clojure -
i've got pretty simple java code:
public class messagelistenerexample extends listeneradapter { @override public void onmessagereceived(messagereceivedevent event) { // event } }
however, can't seem understand how turn code clojure code. docs , articles confusing. i'd happy see more examples too. i'm interested in using implements
.
depending on need do, few options:
- if need extend class (other object) in clojure, can using gen-class, see https://clojuredocs.org/clojure.core/gen-class. preferably using ns macro, like
(ns your.class.name :extends whatever.needs.to.be.extended) (defn -methodyouoverride ; mind dash - it's important [...] ...)
i wouldn't recommend going down path unless absolutely necessary. getting compilation right (including aot compilation) tricky. , in end still need use java interop work objects of class, not sure it's worth hassle, brings me to:
code in java , use java interop work it.
if need create instance of object implements interface, it's easier:
(reify interfaceyouimplement (methodyouimplement [..] ..)
i use around code, it's nicer coding in java.
Comments
Post a Comment