diff src/org/tmatesoft/hg/util/ProgressSupport.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 41a778e3fd31
children 48f993aa2f41
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/ProgressSupport.java	Tue Dec 06 12:57:21 2011 +0100
+++ b/src/org/tmatesoft/hg/util/ProgressSupport.java	Tue Dec 06 14:25:52 2011 +0100
@@ -37,14 +37,9 @@
 		 * @return support object extracted from target or an empty, no-op implementation
 		 */
 		public static ProgressSupport get(Object target) {
-			if (target instanceof ProgressSupport) {
-				return (ProgressSupport) target;
-			}
-			if (target instanceof Adaptable) {
-				ProgressSupport ps = ((Adaptable) target).getAdapter(ProgressSupport.class);
-				if (ps != null) {
-					return ps;
-				}
+			ProgressSupport ps = Adaptable.Factory.getAdapter(target, ProgressSupport.class, null);
+			if (ps != null) {
+				return ps;
 			}
 			return new ProgressSupport() {
 				public void start(int totalUnits) {