Bug 565924 - Add null-aware Helper methods to IProgressMonitor interface
Change-Id: I59370a1e61be564da4a3a500bb85cea07bd91d05
Signed-off-by: Christoph Laeubrich <laeubi@laeubi-soft.de>
diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
index fb17d96..046bb34 100644
--- a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.common; singleton:=true
-Bundle-Version: 3.13.0.qualifier
+Bundle-Version: 3.14.0.qualifier
Bundle-Localization: plugin
Export-Package: org.eclipse.core.internal.boot;x-friends:="org.eclipse.core.resources,org.eclipse.pde.build",
org.eclipse.core.internal.runtime;common=split;mandatory:=common;
diff --git a/bundles/org.eclipse.equinox.common/pom.xml b/bundles/org.eclipse.equinox.common/pom.xml
index ed82784..e21dcb6 100644
--- a/bundles/org.eclipse.equinox.common/pom.xml
+++ b/bundles/org.eclipse.equinox.common/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
- <version>3.13.0-SNAPSHOT</version>
+ <version>3.14.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
index 04562e6..3eb19cb 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
@@ -10,7 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Christoph Läubrich - join with IProgressMonitorWithBlocking
+ * Christoph Laeubrich - join with IProgressMonitorWithBlocking, add null aware helper methods
*******************************************************************************/
package org.eclipse.core.runtime;
@@ -207,4 +207,31 @@
public default void clearBlocked() {
//default implementation does nothing
}
+
+ /**
+ * Calls {@link #done()} on the given monitor if is non-null. If the given monitor is null,
+ * this is a no-op.
+ * @param monitor the monitor to make done, might be <code>null</code>
+ * @since 3.14
+ */
+ static void done(IProgressMonitor monitor) {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Returns a <code>null</code> safe access to the given monitor, for example in cases where a monitor is passed to
+ * a function the implementation can call this method to get a guaranteed non-null monitor reference
+ * @param monitor
+ * the monitor to check
+ * @return the passed monitor instance or {@link NullProgressMonitor} if monitor was <code>null</code>
+ * @since 3.14
+ */
+ static IProgressMonitor nullSafe(IProgressMonitor monitor) {
+ if (monitor == null) {
+ return new NullProgressMonitor();
+ }
+ return monitor;
+ }
}