diff src/org/tmatesoft/hg/util/CancelSupport.java @ 312:f9f3e9b67ccc

Facilitate cancellation and progress reporting in changelog and manifest iterations
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 27 Sep 2011 05:29:12 +0200
parents 41a778e3fd31
children 91d75e1bac9f
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/CancelSupport.java	Mon Sep 26 04:06:04 2011 +0200
+++ b/src/org/tmatesoft/hg/util/CancelSupport.java	Tue Sep 27 05:29:12 2011 +0200
@@ -43,6 +43,17 @@
 		 * @return target if it's capable checking cancellation status or no-op implementation that never cancels.
 				 */
 		public static CancelSupport get(Object target) {
+			CancelSupport cs = get(target, null);
+			if (cs != null) {
+				return cs;
+			}
+			return new CancelSupport() {
+				public void checkCancelled() {
+				}
+			};
+		}
+		
+		public static CancelSupport get(Object target, CancelSupport defaultValue) {
 			if (target instanceof  CancelSupport) {
 				return (CancelSupport) target;
 			}
@@ -52,10 +63,7 @@
 					return cs;
 				}
 			}
-			return new CancelSupport() {
-				public void checkCancelled() {
-				}
-			};
+			return defaultValue;
 		}
 	}