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...