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")
42 private final String path;
47 private final String prefix;
60 this.elements = elements;
68 ObjectUtilities.
equals(other.path, path) &&
69 ObjectUtilities.equals(other.prefix, prefix) &&
70 ObjectUtilities.equals(other.elements, elements);
76 String path = jsonObject.get(
"path").getAsString();
77 String prefix = jsonObject.get(
"prefix").getAsString();
78 List<String> elements = JsonUtilities.decodeStringList(jsonObject.get(
"elements").getAsJsonArray());
83 if (jsonArray ==
null) {
86 ArrayList<ImportedElements> list =
new ArrayList<ImportedElements>(jsonArray.size());
87 Iterator<JsonElement> iterator = jsonArray.iterator();
88 while (iterator.hasNext()) {
89 list.add(fromJson(iterator.next().getAsJsonObject()));
117 HashCodeBuilder builder =
new HashCodeBuilder();
118 builder.append(path);
119 builder.append(prefix);
120 builder.append(elements);
121 return builder.toHashCode();
125 JsonObject jsonObject =
new JsonObject();
126 jsonObject.addProperty(
"path", path);
127 jsonObject.addProperty(
"prefix", prefix);
128 JsonArray jsonArrayElements =
new JsonArray();
129 for (String elt : elements) {
130 jsonArrayElements.add(
new JsonPrimitive(elt));
132 jsonObject.add(
"elements", jsonArrayElements);
138 StringBuilder builder =
new StringBuilder();
140 builder.append(
"path=");
141 builder.append(path +
", ");
142 builder.append(
"prefix=");
143 builder.append(prefix +
", ");
144 builder.append(
"elements=");
145 builder.append(StringUtils.join(elements,
", "));
147 return builder.toString();
static ImportedElements fromJson(JsonObject jsonObject)
static List< ImportedElements > fromJsonArray(JsonArray jsonArray)
boolean equals(Object obj)
ImportedElements(String path, String prefix, List< String > elements)
List< String > getElements()