Java Assert assertInstanceOf(Object obj, Class classType)

Here you can find the source of assertInstanceOf(Object obj, Class classType)

Description

assert Instance Of

License

Open Source License

Declaration

static public final void assertInstanceOf(Object obj, Class classType) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static public final void assertInstanceOf(Object obj, Class classType) {
        if (obj == null) {
            throw new IllegalArgumentException("Argument is null!");
        }/*  w w w  .  j av  a2s .co  m*/

        if (!classType.isInstance(obj)) {
            throw new IllegalArgumentException(
                    "Argument should be instance of " + classType.getName()
                            + ", but now is " + obj.getClass().getName());
        }
    }
}

Related

  1. assertIndex(final String s, final int index)
  2. assertIndex(int index, String msg)
  3. assertInputNotEmpty(final String input, final String message)
  4. assertInstance(final Object object, final Class c)
  5. assertInstance(Object object, Class c)
  6. assertInstanceOf(Object obj, Class expClass)
  7. assertInstanceOf(Object object, Class expectClass)
  8. assertIntegerGreaterThanZero(long number, String name)
  9. assertIntegerNotNegative(String message, int num)