[英]Java passing custom objects to Clojure
I have a .java file that will be called for its public String solve()
method to answer a problem. 我有一个.java文件,该文件将因其
public String solve()
方法而被调用以回答问题。 The method receives project-defined Java class RP, which contains a collection of RF, which each contain a collection of RO, which each contain several RA which, finally, boil down to String, String pairs (a name and a value). 该方法接收项目定义的Java类RP,该类包含RF集合,每个RF集合包含RO,每个RO集合包含RO,每个RA最终分解为String,String对(一个名称和一个值)。 My question is, (how) can I have that solve() method pass its RP object to Clojure where I believe I can do all the work to generate a solution more effectively, and eventually return a String solution back?
我的问题是,(如何)让我的resolve()方法将其RP对象传递给Clojure,我相信我可以完成所有工作以更有效地生成解决方案,并最终返回String解决方案?
EDIT : What I'm looking for is some way of saying, String answer = toClojure(RP);
编辑 :我正在寻找的是一种说的方式,
String answer = toClojure(RP);
and in Clojure I'll be able to do the equivalent of RP.getRF().getRO().getRA().getName(), where each of these functions is defined in the Java classes. 在Clojure中,我将能够执行RP.getRF()。getRO()。getRA()。getName()的等效功能,其中每个功能都在Java类中定义。
Just pass it the object reference, same as you would pass it to a java method. 只需将其传递给对象引用,就如同将其传递给java方法一样。 Clojure doesn't need any special magic to receive java objects.
Clojure不需要任何特殊的魔术即可接收Java对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.