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")
41 private final String
name;
46 private final int explicitFileCount;
51 private final int implicitFileCount;
56 private final int workItemQueueLength;
68 this.explicitFileCount = explicitFileCount;
69 this.implicitFileCount = implicitFileCount;
70 this.workItemQueueLength = workItemQueueLength;
71 this.cacheEntryExceptions = cacheEntryExceptions;
80 other.explicitFileCount == explicitFileCount &&
81 other.implicitFileCount == implicitFileCount &&
82 other.workItemQueueLength == workItemQueueLength &&
83 ObjectUtilities.equals(other.cacheEntryExceptions, cacheEntryExceptions);
89 String
name = jsonObject.get(
"name").getAsString();
90 int explicitFileCount = jsonObject.get(
"explicitFileCount").getAsInt();
91 int implicitFileCount = jsonObject.get(
"implicitFileCount").getAsInt();
92 int workItemQueueLength = jsonObject.get(
"workItemQueueLength").getAsInt();
93 List<String> cacheEntryExceptions = JsonUtilities.decodeStringList(jsonObject.get(
"cacheEntryExceptions").getAsJsonArray());
94 return new ContextData(
name, explicitFileCount, implicitFileCount, workItemQueueLength, cacheEntryExceptions);
98 if (jsonArray ==
null) {
101 ArrayList<ContextData> list =
new ArrayList<ContextData>(jsonArray.size());
102 Iterator<JsonElement> iterator = jsonArray.iterator();
103 while (iterator.hasNext()) {
104 list.add(fromJson(iterator.next().getAsJsonObject()));
113 return cacheEntryExceptions;
120 return explicitFileCount;
127 return implicitFileCount;
141 return workItemQueueLength;
146 HashCodeBuilder
builder =
new HashCodeBuilder();
148 builder.append(explicitFileCount);
149 builder.append(implicitFileCount);
150 builder.append(workItemQueueLength);
151 builder.append(cacheEntryExceptions);
156 JsonObject jsonObject =
new JsonObject();
157 jsonObject.addProperty(
"name",
name);
158 jsonObject.addProperty(
"explicitFileCount", explicitFileCount);
159 jsonObject.addProperty(
"implicitFileCount", implicitFileCount);
160 jsonObject.addProperty(
"workItemQueueLength", workItemQueueLength);
161 JsonArray jsonArrayCacheEntryExceptions =
new JsonArray();
162 for (String elt : cacheEntryExceptions) {
163 jsonArrayCacheEntryExceptions.add(
new JsonPrimitive(elt));
165 jsonObject.add(
"cacheEntryExceptions", jsonArrayCacheEntryExceptions);
171 StringBuilder
builder =
new StringBuilder();
175 builder.append(
"explicitFileCount=");
176 builder.append(explicitFileCount +
", ");
177 builder.append(
"implicitFileCount=");
178 builder.append(implicitFileCount +
", ");
179 builder.append(
"workItemQueueLength=");
180 builder.append(workItemQueueLength +
", ");
181 builder.append(
"cacheEntryExceptions=");
182 builder.append(StringUtils.join(cacheEntryExceptions,
", "));
int getExplicitFileCount()
boolean equals(Object obj)
int getImplicitFileCount()
List< String > getCacheEntryExceptions()
static List< ContextData > fromJsonArray(JsonArray jsonArray)
int getWorkItemQueueLength()
ContextData(String name, int explicitFileCount, int implicitFileCount, int workItemQueueLength, List< String > cacheEntryExceptions)
static ContextData fromJson(JsonObject jsonObject)
DEF_SWITCHES_START aot vmservice shared library name