comparison src/org/tmatesoft/hg/util/CancelSupport.java @ 215:41a778e3fd31

Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 17 May 2011 00:56:54 +0200
parents 1a7a9a20e1f9
children f9f3e9b67ccc
comparison
equal deleted inserted replaced
214:4252faa556cd 215:41a778e3fd31
37 static class Factory { 37 static class Factory {
38 38
39 /** 39 /**
40 * Obtain non-null cancel support object. 40 * Obtain non-null cancel support object.
41 * 41 *
42 * @param target any object (or <code>null</code>) that might have cancel support 42 * @param target any object (or <code>null</code>) that might have cancel support. For <code>null</code>, returns an instance than never cancels.
43 * @return target if it's capable checking cancellation status or no-op implementation that never cancels. 43 * @return target if it's capable checking cancellation status or no-op implementation that never cancels.
44 */ 44 */
45 public static CancelSupport get(Object target) { 45 public static CancelSupport get(Object target) {
46 if (target instanceof CancelSupport) { 46 if (target instanceof CancelSupport) {
47 return (CancelSupport) target; 47 return (CancelSupport) target;
56 public void checkCancelled() { 56 public void checkCancelled() {
57 } 57 }
58 }; 58 };
59 } 59 }
60 } 60 }
61
62 interface Target<T> {
63 T set(CancelSupport cs);
64 }
61 } 65 }