Example #1
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);
      }
    }
  }
Example #2
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);
      }
    }
  }
Example #3
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);
      }
    }
  }
Example #4
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);
      }
    }
  }