Last change
on this file since 14131 was 14131, checked in by Don-vip, 6 years ago |
see #16590 - more fixes (patch by ris)
see #15229 - javadoc fixes
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.spi.lifecycle;
|
---|
3 |
|
---|
4 | import java.util.Objects;
|
---|
5 | import java.util.concurrent.Callable;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Initialization task notifying the current lifecycle {@link InitStatusListener}.
|
---|
9 | * @since 14125
|
---|
10 | */
|
---|
11 | public final class InitializationTask implements Callable<Void> {
|
---|
12 |
|
---|
13 | private final String name;
|
---|
14 | private final Runnable task;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Constructs a new {@code InitializationTask}.
|
---|
18 | * @param name translated name to be displayed to user
|
---|
19 | * @param task runnable initialization task
|
---|
20 | */
|
---|
21 | public InitializationTask(String name, Runnable task) {
|
---|
22 | this.name = Objects.requireNonNull(name);
|
---|
23 | this.task = Objects.requireNonNull(task);
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public Void call() {
|
---|
28 | Object status = null;
|
---|
29 | InitStatusListener initListener = Lifecycle.getInitStatusListener();
|
---|
30 | if (initListener != null) {
|
---|
31 | status = initListener.updateStatus(name);
|
---|
32 | }
|
---|
33 | task.run();
|
---|
34 | if (initListener != null) {
|
---|
35 | initListener.finish(status);
|
---|
36 | }
|
---|
37 | return null;
|
---|
38 | }
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.