comparison src/org/tmatesoft/hg/util/CancelSupport.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents 91d75e1bac9f
children
comparison
equal deleted inserted replaced
422:5d1cc7366d04 423:9c9c442b5f2e
1 /* 1 /*
2 * Copyright (c) 2011 TMate Software Ltd 2 * Copyright (c) 2011-2012 TMate Software Ltd
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License. 6 * the Free Software Foundation; version 2 of the License.
7 * 7 *
45 public static CancelSupport get(Object target) { 45 public static CancelSupport get(Object target) {
46 CancelSupport cs = get(target, null); 46 CancelSupport cs = get(target, null);
47 if (cs != null) { 47 if (cs != null) {
48 return cs; 48 return cs;
49 } 49 }
50 return new CancelSupport() { 50 class NoCancel implements CancelSupport {
51 public void checkCancelled() { 51 public void checkCancelled() {
52 } 52 }
53 }; 53 };
54 return new NoCancel();
54 } 55 }
55 56
56 public static CancelSupport get(Object target, CancelSupport defaultValue) { 57 public static CancelSupport get(Object target, CancelSupport defaultValue) {
57 return Adaptable.Factory.getAdapter(target, CancelSupport.class, defaultValue); 58 return Adaptable.Factory.getAdapter(target, CancelSupport.class, defaultValue);
58 } 59 }