I'm guessing the Type object shouldn't know anything different class types? Otherwise, could this be simplified to a dto.getType().getTaskClass() call?