将集合转为数组

@param <T> 数组元素类型
@param iterable {@link Iterable}
@param componentType 集合元素类型
@return 数组
@since 3.0.9
337921
public static <T> T[] toArray(Iterable<T> iterable, Class<T> componentType) {
		return toArray(CollectionUtil.toCollection(iterable), componentType);
	}
269669
@Override
    public <R> ListT<W,R> unitIterable(final Iterable<R> it) {
        return of(run.unitIterable(it)
                     .map(i -> ListX.of(i)));
    }
766034
public static <T> Iterable<T> simpleIterable(final Iterable<T> iterable) {
        requireNonNull(iterable);
        return () -> iterable.iterator();
    }
334753
List<Expression> parseArrayValueList( IType componentType )
  {
    while( componentType instanceof TypeVariableType )
    {
      componentType = ((TypeVariableType)componentType).getBoundingType();
    }
    List<Expression> valueExpressions = new ArrayList<>();
    do
    {
      parseExpression( new ContextType( componentType ) );
      Expression e = popExpression();
      valueExpressions.add( e );
    }
    while( match( null, ',' ) );

    return valueExpressions;
  }
889614
public static <T> CloseableIterable<T> filter(final CloseableIterable<?> iterable, final Class<T> type) {
        return wrap(Iterables.filter(iterable, type), iterable);
    }
136460
function (root, componentType) {
    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
      return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
    });
  }
1194189
public static <T> Iterable<T> iterable(Enumeration<T> enumeration) {
		LinkedList<T> list = new LinkedList<>();
		while (enumeration.hasMoreElements()) list.add(enumeration.nextElement());
		return list;
	}
535364
public List<FacesConfigComponentType<FacesConfigType<T>>> getAllComponent()
   {
      List<FacesConfigComponentType<FacesConfigType<T>>> list = new ArrayList<FacesConfigComponentType<FacesConfigType<T>>>();
      List<Node> nodeList = childNode.get("component");
      for(Node node: nodeList)
      {
         FacesConfigComponentType<FacesConfigType<T>>  type = new FacesConfigComponentTypeImpl<FacesConfigType<T>>(this, "component", childNode, node);
         list.add(type);
      }
      return list;
   }
379291
private static String convertHessianFormat(String componentType) {

        if (componentType == null) {
            throw new IllegalArgumentException("参数不能为null.");
        }

        int lastIndex = componentType.lastIndexOf(ARRAY_PREFIX);
        if (lastIndex != -1) {

            if (componentType.charAt(componentType.length() - 1) != ';'
                && componentType.charAt(lastIndex + 1) != 'L') {
                throw new IllegalArgumentException("非法数组格式");
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < lastIndex + 1; i++) {
                sb.append(ARRAY_PREFIX);
            }

            sb.append(componentType.substring(lastIndex + 2, componentType.length() - 1));
            return sb.toString();
        }

        return componentType;
    }
62555
public <T> List<T> getComponentInstancesOfType(Class<T> componentType)
   {
      return container.getComponentInstancesOfType(componentType);
   }
562793
private String getComponentType(String componentType) throws SignatureException {

        String JVMSig = "";

        if(componentType != null){
            switch (componentType) {
                case "void":    JVMSig += SIG_VOID;    break;
                case "boolean": JVMSig += SIG_BOOLEAN; break;
                case "byte":    JVMSig += SIG_BYTE;    break;
                case "char":    JVMSig += SIG_CHAR;    break;
                case "short":   JVMSig += SIG_SHORT;   break;
                case "int":     JVMSig += SIG_INT;     break;
                case "long":    JVMSig += SIG_LONG;    break;
                case "float":   JVMSig += SIG_FLOAT;   break;
                case "double":  JVMSig += SIG_DOUBLE;  break;
                default:
                    if (!componentType.equals("")) {
                        TypeElement classNameDoc = elems.getTypeElement(componentType);

                        if (classNameDoc == null) {
                            throw new SignatureException(componentType);
                        }
                        else {
                            String classname = classNameDoc.getQualifiedName().toString();
                            String newclassname = classname.replace('.', '/');
                            JVMSig += "L";
                            JVMSig += newclassname;
                            JVMSig += ";";
                        }
                    }
                    break;
            }
        }
        return JVMSig;
    }
701365
public static <T> Iterable<T> cast(Iterable<?> iterable) {
    return iterable == null ? null : new CastingIterable<T>(iterable);
  }
514351
@NonNull
  public static TupleType tupleOf(@NonNull DataType... componentTypes) {
    return new DefaultTupleType(ImmutableList.copyOf(Arrays.asList(componentTypes)));
  }
344200
@SuppressWarnings("unchecked")
  public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
    Collection<T> collection;
    if (iterable instanceof Collection) {
      collection = (Collection<T>) iterable;
    } else {
      collection = new ArrayList<T>();
      for (T element : iterable) {
        collection.add(element);
      }
    }
    T[] array = (T[]) Array.newInstance(type, collection.size());
    return collection.toArray(array);
  }
1119375
public <T extends Component> T createComponent (Class<T> componentType) {
		try {
			return ClassReflection.newInstance(componentType);
		} catch (ReflectionException e) {
			return null;
		}
	}
570749
static final JSType getElementType(JSType iterableOrIterator, JSTypeRegistry typeRegistry) {
    TemplateTypeMap templateTypeMap =
        iterableOrIterator
            // Remember that `string` will box to a `Iterable`.
            .autobox()
            .getTemplateTypeMap();

    if (templateTypeMap.hasTemplateKey(typeRegistry.getIterableTemplate())) {
      // `Iterable<SomeElementType>` or `Generator<SomeElementType>`
      return templateTypeMap.getResolvedTemplateType(typeRegistry.getIterableTemplate());
    } else if (templateTypeMap.hasTemplateKey(typeRegistry.getIteratorTemplate())) {
      // `Iterator<SomeElementType>`
      return templateTypeMap.getResolvedTemplateType(typeRegistry.getIteratorTemplate());
    } else if (templateTypeMap.hasTemplateKey(typeRegistry.getAsyncIterableTemplate())) {
      // `AsyncIterable<SomeElementType>` or `AsyncGenerator<SomeElementType>`
      return templateTypeMap.getResolvedTemplateType(typeRegistry.getAsyncIterableTemplate());
    } else if (templateTypeMap.hasTemplateKey(typeRegistry.getAsyncIteratorTemplate())) {
      // `AsyncIterator<SomeElementType>`
      return templateTypeMap.getResolvedTemplateType(typeRegistry.getAsyncIteratorTemplate());
    }
    return typeRegistry.getNativeType(UNKNOWN_TYPE);
  }
829629
public static <T> C.List<T> toList(Iterable<? extends T> iterable) {
        if (iterable instanceof Collection) {
            return toList((Collection<T>) iterable);
        }
        ListBuilder<T> lb = new ListBuilder<T>(10);
        for (T t : iterable) {
            lb.add(t);
        }
        return lb.toList();
    }