示例#1
0
  public static void allElementsOfType(Collection collection, Class clazz, String message) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(message);
      }
    }
  }
示例#2
0
  public static void allElementsOfType(Collection collection, Class clazz) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(
            "The validated collection contains an element not of type "
                + clazz.getName()
                + " at index: "
                + i);
      }
    }
  }
示例#3
0
  public static void noNullElements(Object[] array, String message) {
    Validate.notNull(array);

    for (Object array1 : array) {
      if (array1 == null) {
        throw new IllegalArgumentException(message);
      }
    }
  }
示例#4
0
  public static void noNullElements(Collection collection, String message) {
    Validate.notNull(collection);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (it.next() == null) {
        throw new IllegalArgumentException(message);
      }
    }
  }
示例#5
0
  public static void noNullElements(Object[] array) {
    Validate.notNull(array);

    for (int i = 0; i < array.length; i++) {
      if (array[i] == null) {
        throw new IllegalArgumentException(
            "The validated array contains null element at index: " + i);
      }
    }
  }
示例#6
0
  public static void noNullElements(Collection collection) {
    Validate.notNull(collection);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (it.next() == null) {
        throw new IllegalArgumentException(
            "The validated collection contains null element at index: " + i);
      }
    }
  }
示例#7
0
 public static void notNull(Object object) {
   notNull(object, "The validated object is null");
 }