/**
* Casts a sequence of values of a certain type to an array of values of another type, discarding elements that are not cast successfully.
*/
private static <TSource, TDest> void castRemove(final TSource[] values, final ReifiedList<TDest> list)
{
val destinationClass = list.getGenericTypeParameter();
for (TSource v : values)
{
TDest castVal;
try
{
castVal = (TDest) destinationClass.cast(v);
}
catch(ClassCastException e)
{
// remove upon any failure
continue;