次のJavaクラスがあります。
public class Toto {
public void aMethod(A a) {
System.out.println("A " + a);
}
public void aMethod(B b) {
System.out.println("B " + b);
}
}
aMethod(A a) をオーバーライドしたいが、aMethod(B b) はオーバーライドしたくない。私ができる唯一の方法は次のとおりです。
(ns titi
(:gen-class :extends Toto
:exposes-method {aMethod parentMethod}))
(defn- -aMethod [this x]
(if (= (type x) A)
(println "ok do something here")
(.parentMethod this x)))
これを行うより良い方法はありますか?(つまり、 x のタイプを自分でチェックしないことを意味します)。