Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348208 - Consider changing Adaptable#getAdapter(Object) to use a type parameter
Summary: Consider changing Adaptable#getAdapter(Object) to use a type parameter
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.5 M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-03 09:44 EDT by Rüdiger Herrmann CLA
Modified: 2011-10-14 12:00 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.