내가 (방법 체인이 많이 발생)를 유창함 인터페이스 API의 일부로서이 세 가지 인터페이스를 가지고 선언함으로써Java에서 일반적인 확장 인터페이스 메소드를 재사용하는 방법은 무엇입니까?
interface VerifierA extends VerifierC {
VerifierA method1();
// other methods elided
}
interface VerifierB extends VerifierC {
VerifierB method1();
// other methods elided
}
interface VerifierC {
VerifierA commonMethod();
}
commonMethod()
VerifierA
나는 할 수있는 다음 체인 방법 commonMethod().method1()
하지만 commonMethod().method2()
;
어떻게하면 commonMethod()
에 넣을 수 있습니까? VerifierC
필요에 따라 VerifierA
또는 VerifierB 모두로 되돌아 갈 수 있습니까?
을 나는이 이미 http://stackoverflow.com/questions/1069528/method-chaining-inheritance-don-t-play-well-에 요청합니다 생각 함께 또는 http://stackoverflow.com/questions/9655335/method-chaining-how-to-use-getthis-trick-in-case-of-multi-level-inheritance – pringi
참조 된 답변을 읽었을 때, 두려운 인터페이스로만 구성된 내 상황에 적용 할 수 없을까 ... – Andrejs
commonMethod가 VerifierC를 반환하고 VerifierB를 오버라이드하여 VerifierB를 반환하고 VerifierA를 사용하여 VerifierA를 반환하게하는 이유는 무엇입니까? – david