Skip to content

Commit e497695

Browse files
committed
Clean up DefaultIOService style
Separate out whether the opener is null or returns null data. Clean up code style.
1 parent 98ff46d commit e497695

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/java/org/scijava/io/DefaultIOService.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ public <D> IOPlugin<D> getSaver(final D data, final String destination) {
8282

8383
@Override
8484
public Object open(final String source) throws IOException {
85-
IOPlugin<?> opener = getOpener(source);
86-
Object data = null;
87-
if (opener != null) {
88-
data= opener.open(source);
89-
}
90-
if (data != null) {
91-
eventService.publish(new DataOpenedEvent(source, data));
92-
}
85+
final IOPlugin<?> opener = getOpener(source);
86+
if (opener == null) return null; // no appropriate IOPlugin
87+
88+
final Object data = opener.open(source);
89+
if (data == null) return null; // IOPlugin returned no data; canceled?
90+
91+
eventService.publish(new DataOpenedEvent(source, data));
9392
return data;
9493
}
9594

0 commit comments

Comments
 (0)