clojure definterface 可以扩展另一个接口吗?
can clojure definterface extend another interface?
我想将以下代码翻译成 clojure:
package com.example.orbit.hello;
import com.ea.orbit.actors.IActor;
import com.ea.orbit.concurrent.Task;
public interface IHello extends IActor
{
Task<String> sayHello(String greeting);
}
这怎么可能?
您可以简单地定义此接口 Java 并从 Clojure 中使用它。
如果你真的想在 Clojure 中这样做,虽然你必须使用 gen-interface
而不是 definterface
:
(gen-interface
:name fully.qualified.IName
:extends [whatever.it.INeedsTo]
:methods
[[methodName
[fully.qualified.type.of.Argument1 …] ; NB. no `this' formal argument
fully.qualified.ReturnType]])
有关真实世界的示例,请查看 this interface definition in data.avl or this one in ctries.clj(后者使用 :extends
)。
Task<String>
的 <String>
部分将不会出现在 Clojure 版本中 – 泛型是一种 javac
结构,在 JVM 运行时不存在。
我想将以下代码翻译成 clojure:
package com.example.orbit.hello;
import com.ea.orbit.actors.IActor;
import com.ea.orbit.concurrent.Task;
public interface IHello extends IActor
{
Task<String> sayHello(String greeting);
}
这怎么可能?
您可以简单地定义此接口 Java 并从 Clojure 中使用它。
如果你真的想在 Clojure 中这样做,虽然你必须使用 gen-interface
而不是 definterface
:
(gen-interface
:name fully.qualified.IName
:extends [whatever.it.INeedsTo]
:methods
[[methodName
[fully.qualified.type.of.Argument1 …] ; NB. no `this' formal argument
fully.qualified.ReturnType]])
有关真实世界的示例,请查看 this interface definition in data.avl or this one in ctries.clj(后者使用 :extends
)。
Task<String>
的 <String>
部分将不会出现在 Clojure 版本中 – 泛型是一种 javac
结构,在 JVM 运行时不存在。