mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 04:37:32 +07:00
GitOrigin-RevId: ca372c621f208ccba68219f8bf91e43c2958bc63
35 lines
757 B
Java
35 lines
757 B
Java
import com.intellij.util.concurrency.annotations.RequiresReadLock;
|
|
import com.intellij.util.concurrency.ThreadingAssertions;
|
|
|
|
public class SubtypingPolymorphism {
|
|
public void testMethod() {
|
|
Service[] services = {new FileService(), new UIService(), new DatabaseService()};
|
|
for (Service service : services) {
|
|
service.execute();
|
|
}
|
|
}
|
|
}
|
|
|
|
interface Service {
|
|
void execute();
|
|
}
|
|
|
|
class FileService implements Service {
|
|
@Override
|
|
@RequiresReadLock
|
|
public void execute() { }
|
|
}
|
|
|
|
class UIService implements Service {
|
|
@Override
|
|
public void execute() {
|
|
ThreadingAssertions.assertEventDispatchThread();
|
|
}
|
|
}
|
|
|
|
class DBService implements Service {
|
|
@Override
|
|
public void execute() {
|
|
ThreadingAssertions.assertReadAccess();
|
|
}
|
|
} |