Extending Java superclasses and implementing Java interfaces
Java provides a superclass and interface mechanism to provide encapsulation and extendibility. Let's have a look at how to extend existing Java superclasses and implement Java interfaces in Clojure.
Getting ready
In this chapter, we will learn how to define subclasses and how to implement superinterfaces. We will use Jackson and other libraries. So, the :dependencies section in your project.clj as follows:
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/math.numeric-tower "0.0.4"]
[com.fasterxml.jackson.core/jackson-core "2.7.0"]
[com.fasterxml.jackson.core/jackson-databind "2.7.0"]
[com.fasterxml.jackson.core/jackson-annotations "2.7.0"]
]
How to do it...
Let's learn how to use proxy to implement Java interfaces.
Using proxy
proxy generates an anonymous class for superclasses...
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime