com.alibaba.excel.util

类 ListUtils


  • public class ListUtils
    extends Object
    Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
    作者:
    Apache Software Foundation (ASF)
    • 方法详细资料

      • newArrayList

        public static <E> ArrayList<E> newArrayList()
        Creates a mutable, empty ArrayList instance (for Java 6 and earlier).

        Note for Java 7 and later: this method is now unnecessary and should be treated as deprecated. Instead, use the ArrayListconstructor directly, taking advantage of the new "diamond" syntax.

      • newArrayList

        public static <E> ArrayList<E> newArrayList(E... elements)
        Creates a mutable ArrayList instance containing the given elements.
      • newArrayList

        public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
        Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list and then calling Iterators.addAll(java.util.Collection<T>, java.util.Iterator<? extends T>).
      • newArrayList

        public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements)
        Creates a mutable ArrayList instance containing the given elements;

        Note for Java 7 and later: if elements is a Collection, you don't need this method. Use the ArrayListconstructor directly, taking advantage of the new "diamond" syntax.

      • newArrayListWithCapacity

        public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
        Creates an ArrayList instance backed by an array with the specified initial size; simply delegates to ArrayList.ArrayList(int).

        Note for Java 7 and later: this method is now unnecessary and should be treated as deprecated. Instead, use new ArrayList<>(int) directly, taking advantage of the new "diamond" syntax. (Unlike here, there is no risk of overload ambiguity, since the ArrayList constructors very wisely did not accept varargs.)

        参数:
        initialArraySize - the exact size of the initial backing array for the returned array list ( ArrayList documentation calls this value the "capacity")
        返回:
        a new, empty ArrayList which is guaranteed not to resize itself unless its size reaches initialArraySize + 1
        抛出:
        IllegalArgumentException - if initialArraySize is negative
      • newArrayListWithExpectedSize

        public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize)
        Creates an ArrayList instance to hold estimatedSize elements, plus an unspecified amount of padding; you almost certainly mean to call newArrayListWithCapacity(int) (see that method for further advice on usage).

        Note: This method will soon be deprecated. Even in the rare case that you do want some amount of padding, it's best if you choose your desired amount explicitly.

        参数:
        estimatedSize - an estimate of the eventual List.size() of the new list
        返回:
        a new, empty ArrayList, sized appropriately to hold the estimated number of elements
        抛出:
        IllegalArgumentException - if estimatedSize is negative
      • checkNotNull

        public static <T> T checkNotNull(T reference)
        Ensures that an object reference passed as a parameter to the calling method is not null.
        参数:
        reference - an object reference
        返回:
        the non-null reference that was validated
        抛出:
        NullPointerException - if reference is null

Copyright © 2018–2021 Alibaba Group. All rights reserved.