public static void checkNullOrNonNullEntries(
      @Nullable Collection<?> values, String propertyName) {
    if (values == null) {
      // pass
      return;
    }
    for (Object value : values) {
      Preconditions.checkNotNull(
          value, "Property '" + propertyName + "' cannot contain null entries");
    }
  }
Check if a collection is either null, empty or contains only non-null values.

@param values the collection in question
@param propertyName the equivalent 'yaml' property name
@throws NullPointerException if {@code values} contains null entries
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/Validator.java