-
- @SuppressFBWarnings(value = "DCN_NULLPOINTER_EXCEPTION",
- justification = "Internal NPE->IAE conversion")
- private static void checkCollectionField(final @NonNull Class<?> requiredClass,
- final @NonNull String fieldName, final @Nullable Collection<?> collection) {
- if (collection != null) {
- try {
- collection.forEach(item -> requiredClass.cast(requireNonNull(item)));
- } catch (ClassCastException | NullPointerException e) {
- throw new IllegalArgumentException("Invalid input item for property \"" + requireNonNull(fieldName)
- + "\"", e);
- }
- }
- }