Skip to content

Commit

Permalink
renamed JsonArray.contains() to has() to be consistent with JsonObjec…
Browse files Browse the repository at this point in the history
…t.has()
  • Loading branch information
inder123 committed Jul 3, 2014
1 parent 5570114 commit 33418aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gson/src/main/java/com/google/gson/JsonArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void set(int index, JsonElement element) {
* If the array does not contain the element, it is unchanged.
* @param element element to be removed from this array, if present
* @return true if this array contained the specified element, false otherwise
* @since 2.3
*/
public boolean remove(JsonElement element) {
return elements.remove(element);
Expand All @@ -99,6 +100,7 @@ public boolean remove(JsonElement element) {
* @param index index the index of the element to be removed
* @return the element previously at the specified position
* @throws IndexOutOfBoundsException if the specified index is outside the array bounds
* @since 2.3
*/
public JsonElement remove(int index) {
return elements.remove(index);
Expand All @@ -108,8 +110,9 @@ public JsonElement remove(int index) {
* Returns true if this array contains the specified element.
* @return true if this array contains the specified element.
* @param element whose presence in this array is to be tested
* @since 2.3
*/
public boolean contains(JsonElement element) {
public boolean has(JsonElement element) {
return elements.contains(element);
}

Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/JsonArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public void testRemove() {
JsonPrimitive a = new JsonPrimitive("a");
array.add(a);
assertTrue(array.remove(a));
assertFalse(array.contains(a));
assertFalse(array.has(a));
array.add(a);
array.add(new JsonPrimitive("b"));
assertEquals("b", array.remove(1).getAsString());
assertEquals(1, array.size());
assertTrue(array.contains(a));
assertTrue(array.has(a));
}

public void testSet() {
Expand Down

0 comments on commit 33418aa

Please sign in to comment.