code: public Collection<?> toCollection(Object val) {
  
      if (val == null) {
        return Collections.emptyList();
      }
      else if (val instanceof Collection<?>) {
        return (Collection<?>) val;
      }
      else if (val.getClass().isArray()) {
        return newArrayList((Object[]) val);
      }
      else if (val instanceof Map<?,?>) {
        return ((Map<?,?>)val).entrySet();
      }
      else {
        return newArrayList(val);
      }
    }
docs: Coerce to a collection
  
  @param val
  Object to be coerced.
  @return The Collection coerced value.