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;
32@SuppressWarnings(
"unused")
47 private final int[] uris;
52 private final int[]
names;
58 this.strings = strings;
68 ObjectUtilities.
equals(other.strings, strings) &&
69 Arrays.equals(other.uris, uris) &&
70 Arrays.equals(other.names,
names);
76 List<String> strings = JsonUtilities.decodeStringList(jsonObject.get(
"strings").getAsJsonArray());
77 int[] uris = JsonUtilities.decodeIntArray(jsonObject.get(
"uris").getAsJsonArray());
78 int[]
names = JsonUtilities.decodeIntArray(jsonObject.get(
"names").getAsJsonArray());
83 if (jsonArray ==
null) {
86 ArrayList<ImportedElementSet> list =
new ArrayList<ImportedElementSet>(jsonArray.size());
87 Iterator<JsonElement> iterator = jsonArray.iterator();
88 while (iterator.hasNext()) {
89 list.add(fromJson(iterator.next().getAsJsonObject()));
117 HashCodeBuilder
builder =
new HashCodeBuilder();
125 JsonObject jsonObject =
new JsonObject();
126 JsonArray jsonArrayStrings =
new JsonArray();
127 for (String elt : strings) {
128 jsonArrayStrings.add(
new JsonPrimitive(elt));
130 jsonObject.add(
"strings", jsonArrayStrings);
131 JsonArray jsonArrayUris =
new JsonArray();
132 for (
int elt : uris) {
133 jsonArrayUris.add(
new JsonPrimitive(elt));
135 jsonObject.add(
"uris", jsonArrayUris);
136 JsonArray jsonArrayNames =
new JsonArray();
137 for (
int elt :
names) {
138 jsonArrayNames.add(
new JsonPrimitive(elt));
140 jsonObject.add(
"names", jsonArrayNames);
146 StringBuilder
builder =
new StringBuilder();
149 builder.append(StringUtils.join(strings,
", ") +
", ");
151 builder.append(StringUtils.join(uris,
", ") +
", ");
List< String > getStrings()
static ImportedElementSet fromJson(JsonObject jsonObject)
ImportedElementSet(List< String > strings, int[] uris, int[] names)
boolean equals(Object obj)
static List< ImportedElementSet > fromJsonArray(JsonArray jsonArray)
static const char *const names[]