package com.oracle.truffle.tools.dap.types;
import com.oracle.truffle.tools.utils.json.JSONArray;
import com.oracle.truffle.tools.utils.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class SetBreakpointsArguments extends JSONBase {
SetBreakpointsArguments(JSONObject jsonData) {
super(jsonData);
}
public Source getSource() {
return new Source(jsonData.getJSONObject("source"));
}
public SetBreakpointsArguments setSource(Source source) {
jsonData.put("source", source.jsonData);
return this;
}
public List<SourceBreakpoint> getBreakpoints() {
final JSONArray json = jsonData.optJSONArray("breakpoints");
if (json == null) {
return null;
}
final List<SourceBreakpoint> list = new ArrayList<>(json.length());
for (int i = 0; i < json.length(); i++) {
list.add(new SourceBreakpoint(json.getJSONObject(i)));
}
return Collections.unmodifiableList(list);
}
public SetBreakpointsArguments setBreakpoints(List<SourceBreakpoint> breakpoints) {
if (breakpoints != null) {
final JSONArray json = new JSONArray();
for (SourceBreakpoint sourceBreakpoint : breakpoints) {
json.put(sourceBreakpoint.jsonData);
}
jsonData.put("breakpoints", json);
}
return this;
}
public List<Integer> getLines() {
final JSONArray json = jsonData.optJSONArray("lines");
if (json == null) {
return null;
}
final List<Integer> list = new ArrayList<>(json.length());
for (int i = 0; i < json.length(); i++) {
list.add(json.getInt(i));
}
return Collections.unmodifiableList(list);
}
public SetBreakpointsArguments setLines(List<Integer> lines) {
if (lines != null) {
final JSONArray json = new JSONArray();
for (int intValue : lines) {
json.put(intValue);
}
jsonData.put("lines", json);
}
return this;
}
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public Boolean getSourceModified() {
return jsonData.has("sourceModified") ? jsonData.getBoolean("sourceModified") : null;
}
public SetBreakpointsArguments setSourceModified(Boolean sourceModified) {
jsonData.putOpt("sourceModified", sourceModified);
return this;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
SetBreakpointsArguments other = (SetBreakpointsArguments) obj;
if (!Objects.equals(this.getSource(), other.getSource())) {
return false;
}
if (!Objects.equals(this.getBreakpoints(), other.getBreakpoints())) {
return false;
}
if (!Objects.equals(this.getLines(), other.getLines())) {
return false;
}
if (!Objects.equals(this.getSourceModified(), other.getSourceModified())) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + Objects.hashCode(this.getSource());
if (this.getBreakpoints() != null) {
hash = 59 * hash + Objects.hashCode(this.getBreakpoints());
}
if (this.getLines() != null) {
hash = 59 * hash + Objects.hashCode(this.getLines());
}
if (this.getSourceModified() != null) {
hash = 59 * hash + Boolean.hashCode(this.getSourceModified());
}
return hash;
}
public static SetBreakpointsArguments create(Source source) {
final JSONObject json = new JSONObject();
json.put("source", source.jsonData);
return new SetBreakpointsArguments(json);
}
}