9package org.dartlang.analysis.server.protocol;
11import java.util.Arrays;
14import com.google.common.collect.Lists;
15import com.google.dart.server.utilities.general.JsonUtilities;
16import com.google.dart.server.utilities.general.ObjectUtilities;
17import com.google.gson.JsonArray;
18import com.google.gson.JsonElement;
19import com.google.gson.JsonObject;
20import com.google.gson.JsonPrimitive;
21import org.apache.commons.lang3.builder.HashCodeBuilder;
22import java.util.ArrayList;
23import java.util.Iterator;
24import org.apache.commons.lang3.StringUtils;
31@SuppressWarnings(
"unused")
42 private final int uri;
47 private final int[] elements;
54 this.elements = elements;
63 Arrays.
equals(other.elements, elements);
69 int uri = jsonObject.get(
"uri").getAsInt();
70 int[] elements = JsonUtilities.decodeIntArray(jsonObject.get(
"elements").getAsJsonArray());
75 if (jsonArray ==
null) {
78 ArrayList<ExistingImport> list =
new ArrayList<ExistingImport>(jsonArray.size());
79 Iterator<JsonElement> iterator = jsonArray.iterator();
80 while (iterator.hasNext()) {
81 list.add(fromJson(iterator.next().getAsJsonObject()));
103 HashCodeBuilder
builder =
new HashCodeBuilder();
110 JsonObject jsonObject =
new JsonObject();
111 jsonObject.addProperty(
"uri", uri);
112 JsonArray jsonArrayElements =
new JsonArray();
113 for (
int elt : elements) {
114 jsonArrayElements.add(
new JsonPrimitive(elt));
116 jsonObject.add(
"elements", jsonArrayElements);
122 StringBuilder
builder =
new StringBuilder();
127 builder.append(StringUtils.join(elements,
", "));
static ExistingImport fromJson(JsonObject jsonObject)
static List< ExistingImport > fromJsonArray(JsonArray jsonArray)
ExistingImport(int uri, int[] elements)
boolean equals(Object obj)