Skip to content

Commit 2f13834

Browse files
committed
AppService: add method to get foremost app
The new getApp() method returns the first app on the list -- i.e., the one with the highest priority.
1 parent aa612e3 commit 2f13834

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
*/
4343
public interface AppService extends SingletonService<App> {
4444

45+
/** Gets the foremost application (the one with the highest priority). */
46+
App getApp();
47+
4548
/** Gets an application by name. */
4649
App getApp(final String name);
4750

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

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

3434
import java.util.Collections;
3535
import java.util.HashMap;
36+
import java.util.List;
3637
import java.util.Map;
3738

3839
import org.scijava.log.LogService;
@@ -61,6 +62,13 @@ public class DefaultAppService extends AbstractSingletonService<App> implements
6162

6263
// -- AppService methods --
6364

65+
@Override
66+
public App getApp() {
67+
final List<App> appList = getInstances();
68+
if (appList == null || appList.isEmpty()) return null;
69+
return appList.get(0);
70+
}
71+
6472
@Override
6573
public App getApp(final String name) {
6674
return apps().get(name);

0 commit comments

Comments
 (0)