Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ContextData.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 *
6 * This file has been automatically generated. Please do not edit it manually.
7 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8 */
9package org.dartlang.analysis.server.protocol;
10
11import java.util.Arrays;
12import java.util.List;
13import java.util.Map;
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;
25
26/**
27 * Information about an analysis context.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class ContextData {
33
34 public static final ContextData[] EMPTY_ARRAY = new ContextData[0];
35
36 public static final List<ContextData> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The name of the context.
40 */
41 private final String name;
42
43 /**
44 * Explicitly analyzed files.
45 */
46 private final int explicitFileCount;
47
48 /**
49 * Implicitly analyzed files.
50 */
51 private final int implicitFileCount;
52
53 /**
54 * The number of work items in the queue.
55 */
56 private final int workItemQueueLength;
57
58 /**
59 * Exceptions associated with cache entries.
60 */
61 private final List<String> cacheEntryExceptions;
62
63 /**
64 * Constructor for {@link ContextData}.
65 */
66 public ContextData(String name, int explicitFileCount, int implicitFileCount, int workItemQueueLength, List<String> cacheEntryExceptions) {
67 this.name = name;
68 this.explicitFileCount = explicitFileCount;
69 this.implicitFileCount = implicitFileCount;
70 this.workItemQueueLength = workItemQueueLength;
71 this.cacheEntryExceptions = cacheEntryExceptions;
72 }
73
74 @Override
75 public boolean equals(Object obj) {
76 if (obj instanceof ContextData) {
77 ContextData other = (ContextData) obj;
78 return
79 ObjectUtilities.equals(other.name, name) &&
80 other.explicitFileCount == explicitFileCount &&
81 other.implicitFileCount == implicitFileCount &&
82 other.workItemQueueLength == workItemQueueLength &&
83 ObjectUtilities.equals(other.cacheEntryExceptions, cacheEntryExceptions);
84 }
85 return false;
86 }
87
88 public static ContextData fromJson(JsonObject jsonObject) {
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);
95 }
96
97 public static List<ContextData> fromJsonArray(JsonArray jsonArray) {
98 if (jsonArray == null) {
99 return EMPTY_LIST;
100 }
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()));
105 }
106 return list;
107 }
108
109 /**
110 * Exceptions associated with cache entries.
111 */
113 return cacheEntryExceptions;
114 }
115
116 /**
117 * Explicitly analyzed files.
118 */
119 public int getExplicitFileCount() {
120 return explicitFileCount;
121 }
122
123 /**
124 * Implicitly analyzed files.
125 */
126 public int getImplicitFileCount() {
127 return implicitFileCount;
128 }
129
130 /**
131 * The name of the context.
132 */
133 public String getName() {
134 return name;
135 }
136
137 /**
138 * The number of work items in the queue.
139 */
141 return workItemQueueLength;
142 }
143
144 @Override
145 public int hashCode() {
146 HashCodeBuilder builder = new HashCodeBuilder();
147 builder.append(name);
148 builder.append(explicitFileCount);
149 builder.append(implicitFileCount);
150 builder.append(workItemQueueLength);
151 builder.append(cacheEntryExceptions);
152 return builder.toHashCode();
153 }
154
155 public JsonObject toJson() {
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));
164 }
165 jsonObject.add("cacheEntryExceptions", jsonArrayCacheEntryExceptions);
166 return jsonObject;
167 }
168
169 @Override
170 public String toString() {
171 StringBuilder builder = new StringBuilder();
172 builder.append("[");
173 builder.append("name=");
174 builder.append(name + ", ");
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, ", "));
183 builder.append("]");
184 return builder.toString();
185 }
186
187}
static List< ContextData > fromJsonArray(JsonArray jsonArray)
ContextData(String name, int explicitFileCount, int implicitFileCount, int workItemQueueLength, List< String > cacheEntryExceptions)
static ContextData fromJson(JsonObject jsonObject)
const char * name
Definition fuchsia.cc:50