Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterWidgetProperty.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 * A property of a Flutter widget.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final FlutterWidgetProperty[] EMPTY_ARRAY = new FlutterWidgetProperty[0];
35
36 public static final List<FlutterWidgetProperty> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The documentation of the property to show to the user. Omitted if the server does not know the
40 * documentation, e.g. because the corresponding field is not documented.
41 */
42 private final String documentation;
43
44 /**
45 * If the value of this property is set, the Dart code of the expression of this property.
46 */
47 private final String expression;
48
49 /**
50 * The unique identifier of the property, must be passed back to the server when updating the
51 * property value. Identifiers become invalid on any source code change.
52 */
53 private final int id;
54
55 /**
56 * True if the property is required, e.g. because it corresponds to a required parameter of a
57 * constructor.
58 */
59 private final boolean isRequired;
60
61 /**
62 * If the property expression is a concrete value (e.g. a literal, or an enum constant), then it is
63 * safe to replace the expression with another concrete value. In this case this field is true.
64 * Otherwise, for example when the expression is a reference to a field, so that its value is
65 * provided from outside, this field is false.
66 */
67 private final boolean isSafeToUpdate;
68
69 /**
70 * The name of the property to display to the user.
71 */
72 private final String name;
73
74 /**
75 * The list of children properties, if any. For example any property of type EdgeInsets will have
76 * four children properties of type double - left / top / right / bottom.
77 */
78 private final List<FlutterWidgetProperty> children;
79
80 /**
81 * The editor that should be used by the client. This field is omitted if the server does not know
82 * the editor for this property, for example because it does not have one of the supported types.
83 */
84 private final FlutterWidgetPropertyEditor editor;
85
86 /**
87 * If the expression is set, and the server knows the value of the expression, this field is set.
88 */
90
91 /**
92 * Constructor for {@link FlutterWidgetProperty}.
93 */
94 public FlutterWidgetProperty(String documentation, String expression, int id, boolean isRequired, boolean isSafeToUpdate, String name, List<FlutterWidgetProperty> children, FlutterWidgetPropertyEditor editor, FlutterWidgetPropertyValue value) {
95 this.documentation = documentation;
96 this.expression = expression;
97 this.id = id;
98 this.isRequired = isRequired;
99 this.isSafeToUpdate = isSafeToUpdate;
100 this.name = name;
101 this.children = children;
102 this.editor = editor;
103 this.value = value;
104 }
105
106 @Override
107 public boolean equals(Object obj) {
108 if (obj instanceof FlutterWidgetProperty) {
110 return
111 ObjectUtilities.equals(other.documentation, documentation) &&
112 ObjectUtilities.equals(other.expression, expression) &&
113 other.id == id &&
114 other.isRequired == isRequired &&
115 other.isSafeToUpdate == isSafeToUpdate &&
116 ObjectUtilities.equals(other.name, name) &&
117 ObjectUtilities.equals(other.children, children) &&
118 ObjectUtilities.equals(other.editor, editor) &&
119 ObjectUtilities.equals(other.value, value);
120 }
121 return false;
122 }
123
124 public static FlutterWidgetProperty fromJson(JsonObject jsonObject) {
125 String documentation = jsonObject.get("documentation") == null ? null : jsonObject.get("documentation").getAsString();
126 String expression = jsonObject.get("expression") == null ? null : jsonObject.get("expression").getAsString();
127 int id = jsonObject.get("id").getAsInt();
128 boolean isRequired = jsonObject.get("isRequired").getAsBoolean();
129 boolean isSafeToUpdate = jsonObject.get("isSafeToUpdate").getAsBoolean();
130 String name = jsonObject.get("name").getAsString();
131 List<FlutterWidgetProperty> children = jsonObject.get("children") == null ? null : FlutterWidgetProperty.fromJsonArray(jsonObject.get("children").getAsJsonArray());
132 FlutterWidgetPropertyEditor editor = jsonObject.get("editor") == null ? null : FlutterWidgetPropertyEditor.fromJson(jsonObject.get("editor").getAsJsonObject());
133 FlutterWidgetPropertyValue value = jsonObject.get("value") == null ? null : FlutterWidgetPropertyValue.fromJson(jsonObject.get("value").getAsJsonObject());
134 return new FlutterWidgetProperty(documentation, expression, id, isRequired, isSafeToUpdate, name, children, editor, value);
135 }
136
137 public static List<FlutterWidgetProperty> fromJsonArray(JsonArray jsonArray) {
138 if (jsonArray == null) {
139 return EMPTY_LIST;
140 }
141 ArrayList<FlutterWidgetProperty> list = new ArrayList<FlutterWidgetProperty>(jsonArray.size());
142 Iterator<JsonElement> iterator = jsonArray.iterator();
143 while (iterator.hasNext()) {
144 list.add(fromJson(iterator.next().getAsJsonObject()));
145 }
146 return list;
147 }
148
149 /**
150 * The list of children properties, if any. For example any property of type EdgeInsets will have
151 * four children properties of type double - left / top / right / bottom.
152 */
154 return children;
155 }
156
157 /**
158 * The documentation of the property to show to the user. Omitted if the server does not know the
159 * documentation, e.g. because the corresponding field is not documented.
160 */
161 public String getDocumentation() {
162 return documentation;
163 }
164
165 /**
166 * The editor that should be used by the client. This field is omitted if the server does not know
167 * the editor for this property, for example because it does not have one of the supported types.
168 */
170 return editor;
171 }
172
173 /**
174 * If the value of this property is set, the Dart code of the expression of this property.
175 */
176 public String getExpression() {
177 return expression;
178 }
179
180 /**
181 * The unique identifier of the property, must be passed back to the server when updating the
182 * property value. Identifiers become invalid on any source code change.
183 */
184 public int getId() {
185 return id;
186 }
187
188 /**
189 * True if the property is required, e.g. because it corresponds to a required parameter of a
190 * constructor.
191 */
192 public boolean isRequired() {
193 return isRequired;
194 }
195
196 /**
197 * If the property expression is a concrete value (e.g. a literal, or an enum constant), then it is
198 * safe to replace the expression with another concrete value. In this case this field is true.
199 * Otherwise, for example when the expression is a reference to a field, so that its value is
200 * provided from outside, this field is false.
201 */
202 public boolean isSafeToUpdate() {
203 return isSafeToUpdate;
204 }
205
206 /**
207 * The name of the property to display to the user.
208 */
209 public String getName() {
210 return name;
211 }
212
213 /**
214 * If the expression is set, and the server knows the value of the expression, this field is set.
215 */
217 return value;
218 }
219
220 @Override
221 public int hashCode() {
222 HashCodeBuilder builder = new HashCodeBuilder();
223 builder.append(documentation);
224 builder.append(expression);
225 builder.append(id);
226 builder.append(isRequired);
227 builder.append(isSafeToUpdate);
228 builder.append(name);
229 builder.append(children);
230 builder.append(editor);
231 builder.append(value);
232 return builder.toHashCode();
233 }
234
235 public JsonObject toJson() {
236 JsonObject jsonObject = new JsonObject();
237 if (documentation != null) {
238 jsonObject.addProperty("documentation", documentation);
239 }
240 if (expression != null) {
241 jsonObject.addProperty("expression", expression);
242 }
243 jsonObject.addProperty("id", id);
244 jsonObject.addProperty("isRequired", isRequired);
245 jsonObject.addProperty("isSafeToUpdate", isSafeToUpdate);
246 jsonObject.addProperty("name", name);
247 if (children != null) {
248 JsonArray jsonArrayChildren = new JsonArray();
249 for (FlutterWidgetProperty elt : children) {
250 jsonArrayChildren.add(elt.toJson());
251 }
252 jsonObject.add("children", jsonArrayChildren);
253 }
254 if (editor != null) {
255 jsonObject.add("editor", editor.toJson());
256 }
257 if (value != null) {
258 jsonObject.add("value", value.toJson());
259 }
260 return jsonObject;
261 }
262
263 @Override
264 public String toString() {
265 StringBuilder builder = new StringBuilder();
266 builder.append("[");
267 builder.append("documentation=");
268 builder.append(documentation + ", ");
269 builder.append("expression=");
270 builder.append(expression + ", ");
271 builder.append("id=");
272 builder.append(id + ", ");
273 builder.append("isRequired=");
274 builder.append(isRequired + ", ");
275 builder.append("isSafeToUpdate=");
276 builder.append(isSafeToUpdate + ", ");
277 builder.append("name=");
278 builder.append(name + ", ");
279 builder.append("children=");
280 builder.append(StringUtils.join(children, ", ") + ", ");
281 builder.append("editor=");
282 builder.append(editor + ", ");
283 builder.append("value=");
284 builder.append(value);
285 builder.append("]");
286 return builder.toString();
287 }
288
289}
static FlutterWidgetPropertyEditor fromJson(JsonObject jsonObject)
static FlutterWidgetPropertyValue fromJson(JsonObject jsonObject)
FlutterWidgetProperty(String documentation, String expression, int id, boolean isRequired, boolean isSafeToUpdate, String name, List< FlutterWidgetProperty > children, FlutterWidgetPropertyEditor editor, FlutterWidgetPropertyValue value)
static List< FlutterWidgetProperty > fromJsonArray(JsonArray jsonArray)
static FlutterWidgetProperty fromJson(JsonObject jsonObject)
uint8_t value
const char * name
Definition fuchsia.cc:50
const uintptr_t id