如何用Clojure记录实现这个通用Java接口?

如何用Clojure记录实现这个通用Java接口?,clojure,jvm-languages,clojure-java-interop,Clojure,Jvm Languages,Clojure Java Interop,我正在努力实现。它继承自一个通用接口,但显然这并不重要。是: 但我得到了一个错误: java.lang.IllegalArgumentException: Must hint overloaded method: get 我的打字提示错了吗?还有什么不对劲吗 (为在座的各位表示歉意,我认为这里的一个简短问题可能更容易回答)您不能使用defrecord实现带有get方法的类型,因为get已经在java.util.Map上定义,defrecord会自动为您实现。如果您想要实现这个接口,您将不得不放

我正在努力实现。它继承自一个通用接口,但显然这并不重要。是:

但我得到了一个错误:

java.lang.IllegalArgumentException: Must hint overloaded method: get
我的打字提示错了吗?还有什么不对劲吗


(为在座的各位表示歉意,我认为这里的一个简短问题可能更容易回答)

您不能使用defrecord实现带有
get
方法的类型,因为
get
已经在java.util.Map上定义,defrecord会自动为您实现。如果您想要实现这个接口,您将不得不放弃mappiness的细节,而只使用一个普通的deftype。此外,代码中的每一个类型提示都是完全不必要的:编译器知道您要实现的接口的类型,不需要您的帮助来找出它们。

我也同样怀疑,对于类型注释,只是消息似乎在说“添加更多注释!”。非常感谢你的回答,就这样。我遇到了另一个问题,也许你能抽出一点时间?
(defrecord WeirdDate [year month day]
    ReadableInstant
    (^boolean equals  [this ^Object readableInstant] (.equals (as-date this) readableInstant))
    (^int get [this ^DateTimeFieldType type] (get (as-date this) type))
    (^Chronology getChronology [this] (.getChronology (as-date this)))
    (^long getMillis [this] (.getMillis (as-date this)))
    (^DateTimeZone getZone [this] (.getZone (as-date this)))
    (^int hashCode [this] (.hashCode (as-date this)))
    (^boolean isAfter [this ^ReadableInstant instant] (.isAfter (as-date this) instant))
    (^boolean isBefore [this ^ReadableInstant instant] (.isBefore (as-date this) instant))
    (^boolean isEqual [this ^ReadableInstant instant] (.isEqual (as-date this) instant))
    (^boolean isSupported [this ^DateTimeFieldType field] (.isSupported (as-date this) field))
    (^Instant.toInstant [this] (.toInstant (as-date this)))
    (^String toString [this] (.toString (as-date this))))
java.lang.IllegalArgumentException: Must hint overloaded method: get