Flutter Engine
The Flutter Engine
AnalysisStatus.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 * An indication of the current state of analysis.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class AnalysisStatus {
33
34 public static final AnalysisStatus[] EMPTY_ARRAY = new AnalysisStatus[0];
35
36 public static final List<AnalysisStatus> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * True if analysis is currently being performed.
40 */
41 private final boolean isAnalyzing;
42
43 /**
44 * The name of the current target of analysis. This field is omitted if analyzing is false.
45 */
46 private final String analysisTarget;
47
48 /**
49 * Constructor for {@link AnalysisStatus}.
50 */
51 public AnalysisStatus(boolean isAnalyzing, String analysisTarget) {
52 this.isAnalyzing = isAnalyzing;
53 this.analysisTarget = analysisTarget;
54 }
55
56 @Override
57 public boolean equals(Object obj) {
58 if (obj instanceof AnalysisStatus) {
59 AnalysisStatus other = (AnalysisStatus) obj;
60 return
61 other.isAnalyzing == isAnalyzing &&
62 ObjectUtilities.equals(other.analysisTarget, analysisTarget);
63 }
64 return false;
65 }
66
67 public static AnalysisStatus fromJson(JsonObject jsonObject) {
68 boolean isAnalyzing = jsonObject.get("isAnalyzing").getAsBoolean();
69 String analysisTarget = jsonObject.get("analysisTarget") == null ? null : jsonObject.get("analysisTarget").getAsString();
70 return new AnalysisStatus(isAnalyzing, analysisTarget);
71 }
72
73 public static List<AnalysisStatus> fromJsonArray(JsonArray jsonArray) {
74 if (jsonArray == null) {
75 return EMPTY_LIST;
76 }
77 ArrayList<AnalysisStatus> list = new ArrayList<AnalysisStatus>(jsonArray.size());
78 Iterator<JsonElement> iterator = jsonArray.iterator();
79 while (iterator.hasNext()) {
80 list.add(fromJson(iterator.next().getAsJsonObject()));
81 }
82 return list;
83 }
84
85 /**
86 * The name of the current target of analysis. This field is omitted if analyzing is false.
87 */
88 public String getAnalysisTarget() {
89 return analysisTarget;
90 }
91
92 /**
93 * True if analysis is currently being performed.
94 */
95 public boolean isAnalyzing() {
96 return isAnalyzing;
97 }
98
99 @Override
100 public int hashCode() {
101 HashCodeBuilder builder = new HashCodeBuilder();
102 builder.append(isAnalyzing);
103 builder.append(analysisTarget);
104 return builder.toHashCode();
105 }
106
107 public JsonObject toJson() {
108 JsonObject jsonObject = new JsonObject();
109 jsonObject.addProperty("isAnalyzing", isAnalyzing);
110 if (analysisTarget != null) {
111 jsonObject.addProperty("analysisTarget", analysisTarget);
112 }
113 return jsonObject;
114 }
115
116 @Override
117 public String toString() {
118 StringBuilder builder = new StringBuilder();
119 builder.append("[");
120 builder.append("isAnalyzing=");
121 builder.append(isAnalyzing + ", ");
122 builder.append("analysisTarget=");
123 builder.append(analysisTarget);
124 builder.append("]");
125 return builder.toString();
126 }
127
128}
static List< AnalysisStatus > fromJsonArray(JsonArray jsonArray)
AnalysisStatus(boolean isAnalyzing, String analysisTarget)
static AnalysisStatus fromJson(JsonObject jsonObject)