• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Implement interface with clojure

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How can do this in clojure ?




table is an instance of Table . addGeneratedColumn is an method of Table class.
ColumnGenerator is a static interface in Table class and it has a abstract method called generateCell.

How can convert the above code into clojure ?
 
author
Posts: 20
Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of attempting to write code here, check this page: Java Interop. Specifically look under "Implementing Interfaces and Extending Classes" and the proxy macro.
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To following on from Amit's pointer, Clojure has really good Java interop but exactly how you approach a problem depends on exactly what you need to do. For example, you can create an implementation of a Java interface on the fly with reify, you can wrap and extend Java objects with proxy and you can also generate regular .class files with gen-class and its buddies.

You're example is similar to the sort of thing shown in the Clojure community docs for proxy: mouse listener.

I recently blogged about generating .class files to write a log4j appender in Clojure which shows a very different approach.
 
Rajith Gamage
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amit Rathore wrote:Instead of attempting to write code here, check this page: Java Interop. Specifically look under "Implementing Interfaces and Extending Classes" and the proxy macro.



thanks for the reply . Found a way to solve it.
 
Rajith Gamage
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Corfield wrote:To following on from Amit's pointer, Clojure has really good Java interop but exactly how you approach a problem depends on exactly what you need to do. For example, you can create an implementation of a Java interface on the fly with reify, you can wrap and extend Java objects with proxy and you can also generate regular .class files with gen-class and its buddies.

You're example is similar to the sort of thing shown in the Clojure community docs for proxy: mouse listener.

I recently blogged about generating .class files to write a log4j appender in Clojure which shows a very different approach.



thanks for the reply. Had to use $ sign instead of other things.
 
Sean Corfield
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajith Gamage wrote:Had to use $ sign instead of other things.


In Java, when nested classes are compiled they are named like Outer$Inner so if you're referring to nested classes from other languages on the JVM, you often have to use the Outer$Inner form of the name.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic