Java Assert assertRequiredArgs(Object[] methodArgs, int requiredArgs, String methodName)

Here you can find the source of assertRequiredArgs(Object[] methodArgs, int requiredArgs, String methodName)

Description

assert Required Args

License

Open Source License

Declaration

public static void assertRequiredArgs(Object[] methodArgs,
            int requiredArgs, String methodName)
            throws IllegalArgumentException 

Method Source Code

//package com.java2s;
/**//from ww  w.j a va2  s  .  co  m
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

public class Main {
    public static void assertRequiredArgs(Object[] methodArgs,
            int requiredArgs, String methodName)
            throws IllegalArgumentException {
        if (methodArgs == null) {
            throw new IllegalArgumentException(String.format(
                    "Expected %d arguments for %s, got 0", requiredArgs,
                    methodName));
        } else if (methodArgs.length < requiredArgs) {
            throw new IllegalArgumentException(String.format(
                    "Expected %d arguments for %s, got %d", requiredArgs,
                    methodName, methodArgs.length));
        }
    }
}

Related

  1. assertPositive(int val, String msg)
  2. assertPositive(int value)
  3. assertPrecondition(boolean b)
  4. assertQualifiedString(String str, String argName)
  5. assertRange(String label, double value, double min, double max)
  6. assertSame(Object expected, Object actual)
  7. assertSame(Object targetObject0, Object targetObject1)
  8. assertSameClazz(Object object, Object defaults)
  9. assertSameObject(Object obj1, Object obj2)