Example usage for java.lang IllegalArgumentException IllegalArgumentException

List of usage examples for java.lang IllegalArgumentException IllegalArgumentException

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException IllegalArgumentException.

Prototype

public IllegalArgumentException(Throwable cause) 

Source Link

Document

Constructs a new exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:Main.java

public static byte[] appendByteArray(byte[] src, byte[] data) {
    if (src.length <= 0 || data.length <= 0) {
        throw new IllegalArgumentException("\u5b57\u8282\u6570\u7ec4\u53c2\u6570\u9519\u8bef");
    }/*from ww  w.  j a  v a2s. c o  m*/
    byte[] ret = new byte[(src.length + data.length)];
    System.arraycopy(src, 0, ret, 0, src.length);
    System.arraycopy(data, 0, ret, src.length, data.length);
    return ret;
}

From source file:Main.java

static void checkPositiveOrZero(float number, String name) {
    if (number < 0)
        throw new IllegalArgumentException(String.format("%s %f must be positive", name, number));
}

From source file:Main.java

static void checkAngle(int angle) {
    if ((angle < 0) || (angle > 360))
        throw new IllegalArgumentException(String.format("Illegal angle %d: must be >=0 and <= 360",
                new Object[] { Integer.valueOf(angle) }));
}

From source file:Main.java

public static void validateCompressionLevel(int compressionLevel) {
    if (compressionLevel > 9 || compressionLevel < 0)
        throw new IllegalArgumentException("Invalid compression level: " + compressionLevel);
}

From source file:Main.java

static void checkPositiveOrZero(float number, String name) {
    if (number < 0)
        throw new IllegalArgumentException(String.format("%s %d must be positive", name, number));
}

From source file:Main.java

public static int getIndexInTriangle(int n, int i, int j) {
    if (n < 0)
        throw new IllegalArgumentException("Triangle width negative");
    if (i < 0 || i >= n)
        throw new IllegalArgumentException("i = " + i + ", n = " + n);
    if (j < i || j >= n)
        throw new IllegalArgumentException("j = " + j + ", n = " + n);
    return n * i - ((i * i + i) >>> 1) + j;
}

From source file:Main.java

static void assertApiKeyValid(String apiKey) throws IllegalArgumentException {
    if (apiKey == null || apiKey == "") {
        throw new IllegalArgumentException("API key is invalid");
    }// ww w  .  jav  a 2 s.c om
}

From source file:Main.java

static void assertUserIdValid(String userId) throws IllegalArgumentException {
    if (userId == null || userId == "") {
        throw new IllegalArgumentException("API key is invalid");
    }//from   w ww. ja v  a2 s .  co  m
}

From source file:Main.java

public static void requireSameArrayLength(Object[] objects, Object[] objects_) {
    if (objects.length != objects_.length)
        throw new IllegalArgumentException("Length of two arrays are not matched");
}

From source file:Main.java

public static double round(double paramDouble, int paramInt) {
    if (paramInt < 0) {
        throw new IllegalArgumentException("The   scale   must   be   a   positive   integer   or   zero");
    }/*from w  w  w.j  ava 2 s .c  om*/
    return new BigDecimal(Double.toString(paramDouble)).divide(new BigDecimal("1"), paramInt, 5).doubleValue();
}