diff options
author | Christoph Laeubrich | 2020-08-09 16:47:50 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-09-09 14:37:26 +0000 |
commit | 38a7402d9cc8c98aaba04267d2dbabfa2b1c5653 (patch) | |
tree | 878b608bfa13fdd5aa4841814f3543fb945274e7 | |
parent | b3ab49d227b758e93d2d5e7733a5d4c7e637cd46 (diff) | |
download | rt.equinox.bundles-38a7402d9cc8c98aaba04267d2dbabfa2b1c5653.tar.gz rt.equinox.bundles-38a7402d9cc8c98aaba04267d2dbabfa2b1c5653.tar.xz rt.equinox.bundles-38a7402d9cc8c98aaba04267d2dbabfa2b1c5653.zip |
Bug 565924 - Add null-aware Helper methods to IProgressMonitor interfaceI20200914-1800I20200913-1800I20200912-1800I20200912-0010I20200911-1800I20200910-1800I20200910-0100I20200909-1800
Change-Id: I59370a1e61be564da4a3a500bb85cea07bd91d05
Signed-off-by: Christoph Laeubrich <laeubi@laeubi-soft.de>
3 files changed, 30 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF index fb17d96df..046bb34e8 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 @@ Manifest-Version: 1.0 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 ed82784de..e21dcb603 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 04562e6cd..3eb19cb98 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 interface IProgressMonitor { 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; + } } |