comparison 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
comparison
equal deleted inserted replaced
355:f2c11fe7f3e9 356:91d75e1bac9f
203 203
204 public <T> T getAdapter(Class<T> adapterClass) { 204 public <T> T getAdapter(Class<T> adapterClass) {
205 if (CancelSupport.class == adapterClass) { 205 if (CancelSupport.class == adapterClass) {
206 return adapterClass.cast(cancelHelper); 206 return adapterClass.cast(cancelHelper);
207 } 207 }
208 if (delegate instanceof Adaptable) { 208 return Adaptable.Factory.getAdapter(delegate, adapterClass, null);
209 return ((Adaptable) delegate).getAdapter(adapterClass);
210 }
211 if (adapterClass.isInstance(delegate)) {
212 return adapterClass.cast(delegate);
213 }
214 return null;
215 } 209 }
216 } 210 }
217 } 211 }