Skip to content

Commit 2366080

Browse files
committed
AppService: move default method impls to iface
1 parent 9bac6ab commit 2366080

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/main/java/org/scijava/app/AppService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
package org.scijava.app;
3333

34+
import java.util.List;
3435
import java.util.Map;
3536

3637
import org.scijava.plugin.SingletonService;
@@ -44,7 +45,11 @@
4445
public interface AppService extends SingletonService<App>, SciJavaService {
4546

4647
/** Gets the foremost application (the one with the highest priority). */
47-
App getApp();
48+
default App getApp() {
49+
final List<App> appList = getInstances();
50+
if (appList == null || appList.isEmpty()) return null;
51+
return appList.get(0);
52+
}
4853

4954
/** Gets an application by name. */
5055
App getApp(final String name);
@@ -56,4 +61,10 @@ public interface AppService extends SingletonService<App>, SciJavaService {
5661
*/
5762
Map<String, App> getApps();
5863

64+
// -- SingletonService methods --
65+
66+
@Override
67+
default Class<App> getPluginType() {
68+
return App.class;
69+
}
5970
}

src/main/java/org/scijava/app/DefaultAppService.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import java.util.Collections;
3535
import java.util.HashMap;
36-
import java.util.List;
3736
import java.util.Map;
3837

3938
import org.scijava.event.EventHandler;
@@ -66,13 +65,6 @@ public class DefaultAppService extends AbstractSingletonService<App> implements
6665

6766
// -- AppService methods --
6867

69-
@Override
70-
public App getApp() {
71-
final List<App> appList = getInstances();
72-
if (appList == null || appList.isEmpty()) return null;
73-
return appList.get(0);
74-
}
75-
7668
@Override
7769
public App getApp(final String name) {
7870
return apps().get(name);
@@ -83,13 +75,6 @@ public Map<String, App> getApps() {
8375
return apps();
8476
}
8577

86-
// -- SingletonService methods --
87-
88-
@Override
89-
public Class<App> getPluginType() {
90-
return App.class;
91-
}
92-
9378
// -- Event handlers --
9479

9580
@EventHandler(key = "org.scijava.app.AppService#about")

0 commit comments

Comments
 (0)