Код: Выделить всё
interface AService {
method1
method2
}
class Impl1 implements AService {
//both methods implemented
}
class Impl2 implements AService {
//both methods implemented
}
class AnotherService {
void process() {
AService service = factory.getService(...);
if (some logical condition) {
service.method1();
}
}
}
Каков самый чистый способ справиться с этим? ? Было бы лучше ввести в сервисе проверку экземпляра, чтобы убедиться, что экземпляр принадлежит этому конкретному типу, а затем привести его, вызвать метод и удалить метод1 из общего интерфейса?
Подробнее здесь: https://stackoverflow.com/questions/791 ... ring-all-m