com.jetdrone.vertx.yoke.store.json.ChangeAwareJsonArray Maven / Gradle / Ivy
package com.jetdrone.vertx.yoke.store.json;
import java.util.Iterator;
import java.util.List;
import org.vertx.java.core.json.EncodeException;
import org.vertx.java.core.json.JsonArray;
import org.vertx.java.core.json.JsonElement;
import org.vertx.java.core.json.JsonObject;
public class ChangeAwareJsonArray extends ChangeAwareJsonElement {
private final JsonArray inner;
protected ChangeAwareJsonArray(JsonArray jsonArray, ChangeAware notifier) {
super(notifier);
inner = jsonArray;
}
public ChangeAwareJsonArray(JsonArray jsonArray) {
this(jsonArray, false);
}
public ChangeAwareJsonArray(JsonArray jsonArray, boolean initialChanged) {
super(null);
inner = jsonArray;
changed = initialChanged;
}
public ChangeAwareJsonArray addString(String str) {
setChanged();
inner.addString(str);
return this;
}
public ChangeAwareJsonArray addObject(JsonObject value) {
setChanged();
inner.addObject(value);
return this;
}
public ChangeAwareJsonArray addArray(JsonArray value) {
setChanged();
inner.addArray(value);
return this;
}
public ChangeAwareJsonArray addElement(JsonElement value) {
setChanged();
inner.addElement(value);
return this;
}
public ChangeAwareJsonArray addNumber(Number value) {
setChanged();
inner.addNumber(value);
return this;
}
public ChangeAwareJsonArray addBoolean(Boolean value) {
setChanged();
inner.addBoolean(value);
return this;
}
public ChangeAwareJsonArray addBinary(byte[] value) {
setChanged();
inner.addBinary(value);
return this;
}
public ChangeAwareJsonArray add(Object value) {
setChanged();
inner.add(value);
return this;
}
public int size() {
return inner.size();
}
@SuppressWarnings("unchecked")
public T get(int index) {
Object value = inner.get(index);
if (value != null) {
if (value instanceof ChangeAwareJsonArray) {
value = new ChangeAwareJsonArray((JsonArray) value, notifier != null ? notifier : this);
} else if (value instanceof JsonObject) {
value = new ChangeAwareJsonObject((JsonObject) value, notifier != null ? notifier : this);
}
}
return (T) value;
}
public Iterator