Flutter Engine
The Flutter Engine
PubStatus.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 pub execution.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class PubStatus {
33
34 public static final PubStatus[] EMPTY_ARRAY = new PubStatus[0];
35
36 public static final List<PubStatus> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * True if the server is currently running pub to produce a list of package directories.
40 */
41 private final boolean isListingPackageDirs;
42
43 /**
44 * Constructor for {@link PubStatus}.
45 */
46 public PubStatus(boolean isListingPackageDirs) {
47 this.isListingPackageDirs = isListingPackageDirs;
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (obj instanceof PubStatus) {
53 PubStatus other = (PubStatus) obj;
54 return
55 other.isListingPackageDirs == isListingPackageDirs;
56 }
57 return false;
58 }
59
60 public static PubStatus fromJson(JsonObject jsonObject) {
61 boolean isListingPackageDirs = jsonObject.get("isListingPackageDirs").getAsBoolean();
62 return new PubStatus(isListingPackageDirs);
63 }
64
65 public static List<PubStatus> fromJsonArray(JsonArray jsonArray) {
66 if (jsonArray == null) {
67 return EMPTY_LIST;
68 }
69 ArrayList<PubStatus> list = new ArrayList<PubStatus>(jsonArray.size());
70 Iterator<JsonElement> iterator = jsonArray.iterator();
71 while (iterator.hasNext()) {
72 list.add(fromJson(iterator.next().getAsJsonObject()));
73 }
74 return list;
75 }
76
77 /**
78 * True if the server is currently running pub to produce a list of package directories.
79 */
80 public boolean isListingPackageDirs() {
81 return isListingPackageDirs;
82 }
83
84 @Override
85 public int hashCode() {
86 HashCodeBuilder builder = new HashCodeBuilder();
87 builder.append(isListingPackageDirs);
88 return builder.toHashCode();
89 }
90
91 public JsonObject toJson() {
92 JsonObject jsonObject = new JsonObject();
93 jsonObject.addProperty("isListingPackageDirs", isListingPackageDirs);
94 return jsonObject;
95 }
96
97 @Override
98 public String toString() {
99 StringBuilder builder = new StringBuilder();
100 builder.append("[");
101 builder.append("isListingPackageDirs=");
102 builder.append(isListingPackageDirs);
103 builder.append("]");
104 return builder.toString();
105 }
106
107}
PubStatus(boolean isListingPackageDirs)
Definition: PubStatus.java:46
static List< PubStatus > fromJsonArray(JsonArray jsonArray)
Definition: PubStatus.java:65
static PubStatus fromJson(JsonObject jsonObject)
Definition: PubStatus.java:60