what-the-bank/sources/com/google/gson/JsonArray.java

198 lines
5.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.gson;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class JsonArray extends JsonElement implements Iterable<JsonElement> {
private final List<JsonElement> elements;
public JsonArray() {
this.elements = new ArrayList();
}
public JsonArray(int i) {
this.elements = new ArrayList(i);
}
@Override // com.google.gson.JsonElement
public final JsonArray deepCopy() {
if (!this.elements.isEmpty()) {
JsonArray jsonArray = new JsonArray(this.elements.size());
Iterator<JsonElement> it = this.elements.iterator();
while (it.hasNext()) {
jsonArray.add(it.next().deepCopy());
}
return jsonArray;
}
return new JsonArray();
}
public final void add(Boolean bool) {
this.elements.add(bool == null ? JsonNull.INSTANCE : new JsonPrimitive(bool));
}
public final void add(Character ch) {
this.elements.add(ch == null ? JsonNull.INSTANCE : new JsonPrimitive(ch));
}
public final void add(Number number) {
this.elements.add(number == null ? JsonNull.INSTANCE : new JsonPrimitive(number));
}
public final void add(String str) {
this.elements.add(str == null ? JsonNull.INSTANCE : new JsonPrimitive(str));
}
public final void add(JsonElement jsonElement) {
if (jsonElement == null) {
jsonElement = JsonNull.INSTANCE;
}
this.elements.add(jsonElement);
}
public final void addAll(JsonArray jsonArray) {
this.elements.addAll(jsonArray.elements);
}
public final JsonElement set(int i, JsonElement jsonElement) {
return this.elements.set(i, jsonElement);
}
public final boolean remove(JsonElement jsonElement) {
return this.elements.remove(jsonElement);
}
public final JsonElement remove(int i) {
return this.elements.remove(i);
}
public final boolean contains(JsonElement jsonElement) {
return this.elements.contains(jsonElement);
}
public final int size() {
return this.elements.size();
}
public final boolean isEmpty() {
return this.elements.isEmpty();
}
@Override // java.lang.Iterable
public final Iterator<JsonElement> iterator() {
return this.elements.iterator();
}
public final JsonElement get(int i) {
return this.elements.get(i);
}
@Override // com.google.gson.JsonElement
public final Number getAsNumber() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsNumber();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final String getAsString() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsString();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final double getAsDouble() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsDouble();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final BigDecimal getAsBigDecimal() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBigDecimal();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final BigInteger getAsBigInteger() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBigInteger();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final float getAsFloat() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsFloat();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final long getAsLong() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsLong();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final int getAsInt() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsInt();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final byte getAsByte() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final char getAsCharacter() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsCharacter();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final short getAsShort() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsShort();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public final boolean getAsBoolean() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBoolean();
}
throw new IllegalStateException();
}
public final boolean equals(Object obj) {
return obj == this || ((obj instanceof JsonArray) && ((JsonArray) obj).elements.equals(this.elements));
}
public final int hashCode() {
return this.elements.hashCode();
}
}