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")
46 private final String kind;
53 private final boolean isPotential;
65 this.location = location;
67 this.isPotential = isPotential;
76 ObjectUtilities.
equals(other.location, location) &&
77 ObjectUtilities.equals(other.kind, kind) &&
78 other.isPotential == isPotential &&
79 ObjectUtilities.equals(other.path, path);
86 String kind = jsonObject.get(
"kind").getAsString();
87 boolean isPotential = jsonObject.get(
"isPotential").getAsBoolean();
89 return new SearchResult(location, kind, isPotential, path);
93 if (jsonArray ==
null) {
96 ArrayList<SearchResult> list =
new ArrayList<SearchResult>(jsonArray.size());
97 Iterator<JsonElement> iterator = jsonArray.iterator();
98 while (iterator.hasNext()) {
99 list.add(fromJson(iterator.next().getAsJsonObject()));
137 HashCodeBuilder builder =
new HashCodeBuilder();
138 builder.append(location);
139 builder.append(kind);
140 builder.append(isPotential);
141 builder.append(path);
142 return builder.toHashCode();
146 JsonObject jsonObject =
new JsonObject();
147 jsonObject.add(
"location", location.
toJson());
148 jsonObject.addProperty(
"kind", kind);
149 jsonObject.addProperty(
"isPotential", isPotential);
150 JsonArray jsonArrayPath =
new JsonArray();
152 jsonArrayPath.add(elt.toJson());
154 jsonObject.add(
"path", jsonArrayPath);
160 StringBuilder builder =
new StringBuilder();
162 builder.append(
"location=");
163 builder.append(location +
", ");
164 builder.append(
"kind=");
165 builder.append(kind +
", ");
166 builder.append(
"isPotential=");
167 builder.append(isPotential +
", ");
168 builder.append(
"path=");
169 builder.append(StringUtils.join(path,
", "));
171 return builder.toString();
static List< Element > fromJsonArray(JsonArray jsonArray)
static Location fromJson(JsonObject jsonObject)
List< Element > getPath()
static List< SearchResult > fromJsonArray(JsonArray jsonArray)
SearchResult(Location location, String kind, boolean isPotential, List< Element > path)
static SearchResult fromJson(JsonObject jsonObject)
boolean equals(Object obj)