Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterOutlineAttribute.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 attribute for a FlutterOutline.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final FlutterOutlineAttribute[] EMPTY_ARRAY = new FlutterOutlineAttribute[0];
35
36 public static final List<FlutterOutlineAttribute> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The name of the attribute.
40 */
41 private final String name;
42
43 /**
44 * The label of the attribute value, usually the Dart code. It might be quite long, the client
45 * should abbreviate as needed.
46 */
47 private final String label;
48
49 /**
50 * The boolean literal value of the attribute. This field is absent if the value is not a boolean
51 * literal.
52 */
53 private final Boolean literalValueBoolean;
54
55 /**
56 * The integer literal value of the attribute. This field is absent if the value is not an integer
57 * literal.
58 */
59 private final Integer literalValueInteger;
60
61 /**
62 * The string literal value of the attribute. This field is absent if the value is not a string
63 * literal.
64 */
65 private final String literalValueString;
66
67 /**
68 * If the attribute is a named argument, the location of the name, without the colon.
69 */
70 private final Location nameLocation;
71
72 /**
73 * The location of the value.
74 *
75 * This field is always available, but marked optional for backward compatibility between new
76 * clients with older servers.
77 */
78 private final Location valueLocation;
79
80 /**
81 * Constructor for {@link FlutterOutlineAttribute}.
82 */
83 public FlutterOutlineAttribute(String name, String label, Boolean literalValueBoolean, Integer literalValueInteger, String literalValueString, Location nameLocation, Location valueLocation) {
84 this.name = name;
85 this.label = label;
86 this.literalValueBoolean = literalValueBoolean;
87 this.literalValueInteger = literalValueInteger;
88 this.literalValueString = literalValueString;
89 this.nameLocation = nameLocation;
90 this.valueLocation = valueLocation;
91 }
92
93 @Override
94 public boolean equals(Object obj) {
95 if (obj instanceof FlutterOutlineAttribute) {
97 return
98 ObjectUtilities.equals(other.name, name) &&
99 ObjectUtilities.equals(other.label, label) &&
100 ObjectUtilities.equals(other.literalValueBoolean, literalValueBoolean) &&
101 ObjectUtilities.equals(other.literalValueInteger, literalValueInteger) &&
102 ObjectUtilities.equals(other.literalValueString, literalValueString) &&
103 ObjectUtilities.equals(other.nameLocation, nameLocation) &&
104 ObjectUtilities.equals(other.valueLocation, valueLocation);
105 }
106 return false;
107 }
108
109 public static FlutterOutlineAttribute fromJson(JsonObject jsonObject) {
110 String name = jsonObject.get("name").getAsString();
111 String label = jsonObject.get("label").getAsString();
112 Boolean literalValueBoolean = jsonObject.get("literalValueBoolean") == null ? null : jsonObject.get("literalValueBoolean").getAsBoolean();
113 Integer literalValueInteger = jsonObject.get("literalValueInteger") == null ? null : jsonObject.get("literalValueInteger").getAsInt();
114 String literalValueString = jsonObject.get("literalValueString") == null ? null : jsonObject.get("literalValueString").getAsString();
115 Location nameLocation = jsonObject.get("nameLocation") == null ? null : Location.fromJson(jsonObject.get("nameLocation").getAsJsonObject());
116 Location valueLocation = jsonObject.get("valueLocation") == null ? null : Location.fromJson(jsonObject.get("valueLocation").getAsJsonObject());
117 return new FlutterOutlineAttribute(name, label, literalValueBoolean, literalValueInteger, literalValueString, nameLocation, valueLocation);
118 }
119
120 public static List<FlutterOutlineAttribute> fromJsonArray(JsonArray jsonArray) {
121 if (jsonArray == null) {
122 return EMPTY_LIST;
123 }
124 ArrayList<FlutterOutlineAttribute> list = new ArrayList<FlutterOutlineAttribute>(jsonArray.size());
125 Iterator<JsonElement> iterator = jsonArray.iterator();
126 while (iterator.hasNext()) {
127 list.add(fromJson(iterator.next().getAsJsonObject()));
128 }
129 return list;
130 }
131
132 /**
133 * The label of the attribute value, usually the Dart code. It might be quite long, the client
134 * should abbreviate as needed.
135 */
136 public String getLabel() {
137 return label;
138 }
139
140 /**
141 * The boolean literal value of the attribute. This field is absent if the value is not a boolean
142 * literal.
143 */
144 public Boolean getLiteralValueBoolean() {
145 return literalValueBoolean;
146 }
147
148 /**
149 * The integer literal value of the attribute. This field is absent if the value is not an integer
150 * literal.
151 */
152 public Integer getLiteralValueInteger() {
153 return literalValueInteger;
154 }
155
156 /**
157 * The string literal value of the attribute. This field is absent if the value is not a string
158 * literal.
159 */
160 public String getLiteralValueString() {
161 return literalValueString;
162 }
163
164 /**
165 * The name of the attribute.
166 */
167 public String getName() {
168 return name;
169 }
170
171 /**
172 * If the attribute is a named argument, the location of the name, without the colon.
173 */
175 return nameLocation;
176 }
177
178 /**
179 * The location of the value.
180 *
181 * This field is always available, but marked optional for backward compatibility between new
182 * clients with older servers.
183 */
185 return valueLocation;
186 }
187
188 @Override
189 public int hashCode() {
190 HashCodeBuilder builder = new HashCodeBuilder();
191 builder.append(name);
192 builder.append(label);
193 builder.append(literalValueBoolean);
194 builder.append(literalValueInteger);
195 builder.append(literalValueString);
196 builder.append(nameLocation);
197 builder.append(valueLocation);
198 return builder.toHashCode();
199 }
200
201 public JsonObject toJson() {
202 JsonObject jsonObject = new JsonObject();
203 jsonObject.addProperty("name", name);
204 jsonObject.addProperty("label", label);
205 if (literalValueBoolean != null) {
206 jsonObject.addProperty("literalValueBoolean", literalValueBoolean);
207 }
208 if (literalValueInteger != null) {
209 jsonObject.addProperty("literalValueInteger", literalValueInteger);
210 }
211 if (literalValueString != null) {
212 jsonObject.addProperty("literalValueString", literalValueString);
213 }
214 if (nameLocation != null) {
215 jsonObject.add("nameLocation", nameLocation.toJson());
216 }
217 if (valueLocation != null) {
218 jsonObject.add("valueLocation", valueLocation.toJson());
219 }
220 return jsonObject;
221 }
222
223 @Override
224 public String toString() {
225 StringBuilder builder = new StringBuilder();
226 builder.append("[");
227 builder.append("name=");
228 builder.append(name + ", ");
229 builder.append("label=");
230 builder.append(label + ", ");
231 builder.append("literalValueBoolean=");
232 builder.append(literalValueBoolean + ", ");
233 builder.append("literalValueInteger=");
234 builder.append(literalValueInteger + ", ");
235 builder.append("literalValueString=");
236 builder.append(literalValueString + ", ");
237 builder.append("nameLocation=");
238 builder.append(nameLocation + ", ");
239 builder.append("valueLocation=");
240 builder.append(valueLocation);
241 builder.append("]");
242 return builder.toString();
243 }
244
245}
static List< FlutterOutlineAttribute > fromJsonArray(JsonArray jsonArray)
FlutterOutlineAttribute(String name, String label, Boolean literalValueBoolean, Integer literalValueInteger, String literalValueString, Location nameLocation, Location valueLocation)
static FlutterOutlineAttribute fromJson(JsonObject jsonObject)
static Location fromJson(JsonObject jsonObject)
const char * name
Definition fuchsia.cc:50