Not sure what this is giving us. You can still catch a 
ClassCastException if the returned value cannot be cast to the type you 
are requiring. We would just be changing the place where the expected 
class is declared, from something like (MyClass)service.getHandle() .... 
to  service.<MyClass>getHandle()

Carlos A. Munoz
Senior Software Engineer
Engineering - Internationalization
Red Hat

On 08/26/2013 12:25 PM, David Mason wrote:
> In zanata-war/src/main/java/org/zanata/service/AsyncTaskManagerService.java:
>
>> +import org.zanata.async.AsyncTaskHandle;
>> +
>> +/**
>> + * @author Carlos Munoz <a href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
>> + */
>> +public interface AsyncTaskManagerService
>> +{
>> +   <V, H extends AsyncTaskHandle<V>> String startTask(AsyncTask<V, H> task);
>> +
>> +   <V, H extends AsyncTaskHandle<V>> void startTask(AsyncTask<V, H> task, Serializable key);
>> +
>> +   AsyncTaskHandle getHandle(String taskId);
>> +
>> +   AsyncTaskHandle getHandleByKey(Serializable key);
>> +
>> +   AsyncTaskHandle getHandle(String taskId, boolean removeIfFinished);
>
> These getter methods could probably be made generic for better errors
> when they're not used properly. e.g. the following call would let us
> catch the |ClassCastException| in the getter and throw a more
> appropriate exception saying that the task with the given id is not of
> the expected type.
>
> MyAsyncTaskHandle  handle  =  asyncTaskManagerServiceImpl.<MyAsyncTaskHandle>getHandle(myTaskId);
>
> The only potential issue is that if we want to use it without a cast it
> might not be as nice to work with.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/zanata/zanata-server/pull/141/files#r5970665>.
>