code: private static Iterable<?> iterable(final Object object)
    {
      // at this point object cannot be null and is array or collection
  
      if(object instanceof Iterable) {
        return (Iterable<?>)object;
      }
  
      // at this point object is an array
      // create a iterator able to traverse generic arrays
  
      return new Iterable<Object>()
      {
        private Object array = object;
        private int index;
  
        @Override
        public Iterator<Object> iterator()
        {
          return new Iterator<Object>()
          {
            @SuppressWarnings("unqualified-field-access")
            @Override
            public boolean hasNext()
            {
              return index < Array.getLength(array);
            }
  
            @SuppressWarnings("unqualified-field-access")
            @Override
            public Object next()
            {
              return Array.get(array, index++);
            }
  
            @Override
            public void remove()
            {
              throw new UnsupportedOperationException("Array iterator has no remove operation.");
            }
          };
        }
      };
    }
docs: Create an iterator supplied via Iterable interface. If <code>object</code> argument is a collection just returns it
  since collection is already iterbale. If is array, create an iterator able to traverse generic arrays.
  
  @param object collection or array.
  @return Iterable instance.