Java Assert assertArrayType(Object array)

Here you can find the source of assertArrayType(Object array)

Description

Assert the object is array or not

License

Apache License

Parameter

Parameter Description
array asserted object

Exception

Parameter Description
IllegalArgumentException if the object is not a array

Declaration

public static void assertArrayType(Object array) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  w w w.jav a2  s  .co m
     * Assert the object is array or not
     *
     * @param array
     *         asserted object
     * @throws IllegalArgumentException
     *         if the object is not a array
     */
    public static void assertArrayType(Object array) throws IllegalArgumentException {
        Class<?> type = array.getClass();
        if (!type.isArray()) {
            String message = String.format("The argument is not an array object, its type is %s", type.getName());
            throw new IllegalArgumentException(message);
        }
    }
}

Related

  1. assertArgNotEmptyString(String value, String argName)
  2. assertArgumentNotMinusInteger(String name, int value)
  3. assertArrayIndex(int arrayLength, int offset, int length)
  4. assertArrayIndexScale(final String name, int actualIndexScale, int expectedIndexScale)
  5. assertAssertionsEnabled()
  6. assertAttributeNameIsLegal(final String attributeName)
  7. assertBounds(final long reqOff, final long reqLen, final long allocSize)
  8. assertByThrowing(boolean condition, String errorMessage)