Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348208

Summary: Consider changing Adaptable#getAdapter(Object) to use a type parameter
Product: [RT] RAP Reporter: Rüdiger Herrmann <ruediger.herrmann>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: 1.5 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Rüdiger Herrmann CLA 2011-06-03 09:44:20 EDT
Adaptable#getAdapter(Object) could be changed to
  <T> T getAdapter( Class<T> adapter )

This would make casting the result of getAdapter() calls obsolete. Client code could be simplified from
  IWidgetAdapter adapter = ( IWidgetAdapter )widget.getAdapter( IWidgetAdapter.class );
to  
  IWidgetAdapter adapter = widget.getAdapter( IWidgetAdapter.class );

Though there are possible implications:
* not sure if this change would be backwards compatible
* a use case that is used in some places in RWT would have to be rewritten
  Bar barAdapter = x.getAdapter( Foo.class );
Comment 1 Rüdiger Herrmann CLA 2011-10-14 12:00:55 EDT
I can't see that this change would affect backwards comptibility except for clients that use code like
  Bar barAdapter = x.getAdapter( Foo.class );
Since the documentation states that getAdapter() must return "an object castable to the given class or null", the above use-case wasn't valid anyway. Therefor I decided to do the propsed changes.
Changes are in CVS HEAD.