Commit 8d97e1f9 authored by Rajiv Prabhakar's avatar Rajiv Prabhakar
Browse files

v1.13.1 release: JsonUtilc.iterator now throws NoSuchElementException and not...

v1.13.1 release: JsonUtilc.iterator now throws NoSuchElementException and not IllegalArgumentException if next() is erraneously called
parent 31016c8f
Pipeline #14633427 failed with stage
in 1 minute and 23 seconds
......@@ -6,7 +6,7 @@
<groupId>com.rajivprab</groupId>
<artifactId>cava</artifactId>
<version>1.13.0</version>
<version>1.13.1</version>
<name>Cava: Clean Java</name>
<description>A library that enables users to write minimal, clean and simple Java</description>
......
package org.rajivprab.cava;
import com.google.common.collect.Streams;
import org.apache.commons.lang3.Validate;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Set;
import java.util.*;
import java.util.stream.Stream;
/**
......@@ -90,15 +86,14 @@ public class JsonUtilc {
@Override
public boolean hasNext() {
Validatec.equals(length, array.length(),
"Array length has changed", ConcurrentModificationException.class);
Validatec.equals(length, array.length(), "Array length has changed", ConcurrentModificationException.class);
return length > nextIndex;
}
@Override
@SuppressWarnings("unchecked")
public T next() {
Validate.isTrue(hasNext(), "Calling next on JSONArray.iterator when hasNext() == false");
Validatec.isTrue(hasNext(), "Next element does not exist", NoSuchElementException.class);
nextIndex++;
return (T) array.get(nextIndex - 1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment