Converting from java.lang.Object
directly to ArrayList<T>
which has elements of T is not recommended as it can lead to casting Exceptions. The recommended way is to first convert to a primitive array of T
and then use Arrays.asList(T[])
One of the ways how you get entity from a java javax.ws.rs.core.Response
is as follows -
T[] t_array = response.readEntity(object);
ArrayList<T> t_arraylist = Arrays.asList(t_array);
You will still get Unchecked cast warnings.