Added check for null values in collection passed to CompilerConfiguration.

This commit is contained in:
Evgeny Gerashchenko
2012-09-13 19:05:02 +04:00
parent 08fc54d969
commit e83a9b7eaa
@@ -70,6 +70,7 @@ public class CompilerConfiguration {
public <T> void addAll(@NotNull CompilerConfigurationKey<List<T>> key, @NotNull Collection<T> values) {
checkReadOnly();
checkForNullElements(values);
Key<List<T>> ideaKey = key.ideaKey;
if (map.get(ideaKey) == null) {
map.put(ideaKey, new ArrayList<T>());
@@ -112,4 +113,15 @@ public class CompilerConfiguration {
return object;
}
}
private static <T> void checkForNullElements(Collection<T> values) {
int index = 0;
for (T value : values) {
if (value == null) {
throw new IllegalArgumentException("Element " + index
+ " is null, while null values in compiler configuration are not allowed");
}
index++;
}
}
}