diff src/org/tmatesoft/hg/core/HgCatCommand.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 5f9073eabf06
children 2fadf8695f8a
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCatCommand.java	Tue Dec 06 12:57:21 2011 +0100
+++ b/src/org/tmatesoft/hg/core/HgCatCommand.java	Tue Dec 06 14:25:52 2011 +0100
@@ -205,13 +205,7 @@
 			if (CancelSupport.class == adapterClass) {
 				return adapterClass.cast(cancelHelper);
 			}
-			if (delegate instanceof Adaptable) {
-				return ((Adaptable) delegate).getAdapter(adapterClass);
-			}
-			if (adapterClass.isInstance(delegate)) {
-				return adapterClass.cast(delegate);
-			}
-			return null;
+			return Adaptable.Factory.getAdapter(delegate, adapterClass, null);
 		}
 	}
 }