Mercurial > hg4j
diff src/org/tmatesoft/hg/util/CancelSupport.java @ 356:91d75e1bac9f
Consistent approach to deal with adaptable objects. Give adaptable precedence over instanceof to allow conditional response when classes do implement desired interface
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Dec 2011 14:25:52 +0100 |
parents | f9f3e9b67ccc |
children | 9c9c442b5f2e |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/CancelSupport.java Tue Dec 06 12:57:21 2011 +0100 +++ b/src/org/tmatesoft/hg/util/CancelSupport.java Tue Dec 06 14:25:52 2011 +0100 @@ -54,16 +54,7 @@ } public static CancelSupport get(Object target, CancelSupport defaultValue) { - if (target instanceof CancelSupport) { - return (CancelSupport) target; - } - if (target instanceof Adaptable) { - CancelSupport cs = ((Adaptable) target).getAdapter(CancelSupport.class); - if (cs != null) { - return cs; - } - } - return defaultValue; + return Adaptable.Factory.getAdapter(target, CancelSupport.class, defaultValue); } }