Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterWidgetPropertyValue.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 value of a property of a Flutter widget.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final FlutterWidgetPropertyValue[] EMPTY_ARRAY = new FlutterWidgetPropertyValue[0];
35
36 public static final List<FlutterWidgetPropertyValue> EMPTY_LIST = Lists.newArrayList();
37
38 private final Boolean boolValue;
39
40 private final Double doubleValue;
41
42 private final Integer intValue;
43
44 private final String stringValue;
45
46 private final FlutterWidgetPropertyValueEnumItem enumValue;
47
48 /**
49 * A free-form expression, which will be used as the value as is.
50 */
51 private final String expression;
52
53 /**
54 * Constructor for {@link FlutterWidgetPropertyValue}.
55 */
56 public FlutterWidgetPropertyValue(Boolean boolValue, Double doubleValue, Integer intValue, String stringValue, FlutterWidgetPropertyValueEnumItem enumValue, String expression) {
57 this.boolValue = boolValue;
58 this.doubleValue = doubleValue;
59 this.intValue = intValue;
60 this.stringValue = stringValue;
61 this.enumValue = enumValue;
62 this.expression = expression;
63 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (obj instanceof FlutterWidgetPropertyValue) {
69 return
70 ObjectUtilities.equals(other.boolValue, boolValue) &&
71 ObjectUtilities.equals(other.doubleValue, doubleValue) &&
72 ObjectUtilities.equals(other.intValue, intValue) &&
73 ObjectUtilities.equals(other.stringValue, stringValue) &&
74 ObjectUtilities.equals(other.enumValue, enumValue) &&
75 ObjectUtilities.equals(other.expression, expression);
76 }
77 return false;
78 }
79
80 public static FlutterWidgetPropertyValue fromJson(JsonObject jsonObject) {
81 Boolean boolValue = jsonObject.get("boolValue") == null ? null : jsonObject.get("boolValue").getAsBoolean();
82 Double doubleValue = jsonObject.get("doubleValue") == null ? null : jsonObject.get("doubleValue").getAsDouble();
83 Integer intValue = jsonObject.get("intValue") == null ? null : jsonObject.get("intValue").getAsInt();
84 String stringValue = jsonObject.get("stringValue") == null ? null : jsonObject.get("stringValue").getAsString();
85 FlutterWidgetPropertyValueEnumItem enumValue = jsonObject.get("enumValue") == null ? null : FlutterWidgetPropertyValueEnumItem.fromJson(jsonObject.get("enumValue").getAsJsonObject());
86 String expression = jsonObject.get("expression") == null ? null : jsonObject.get("expression").getAsString();
87 return new FlutterWidgetPropertyValue(boolValue, doubleValue, intValue, stringValue, enumValue, expression);
88 }
89
90 public static List<FlutterWidgetPropertyValue> fromJsonArray(JsonArray jsonArray) {
91 if (jsonArray == null) {
92 return EMPTY_LIST;
93 }
94 ArrayList<FlutterWidgetPropertyValue> list = new ArrayList<FlutterWidgetPropertyValue>(jsonArray.size());
95 Iterator<JsonElement> iterator = jsonArray.iterator();
96 while (iterator.hasNext()) {
97 list.add(fromJson(iterator.next().getAsJsonObject()));
98 }
99 return list;
100 }
101
102 public Boolean getBoolValue() {
103 return boolValue;
104 }
105
106 public Double getDoubleValue() {
107 return doubleValue;
108 }
109
111 return enumValue;
112 }
113
114 /**
115 * A free-form expression, which will be used as the value as is.
116 */
117 public String getExpression() {
118 return expression;
119 }
120
121 public Integer getIntValue() {
122 return intValue;
123 }
124
125 public String getStringValue() {
126 return stringValue;
127 }
128
129 @Override
130 public int hashCode() {
131 HashCodeBuilder builder = new HashCodeBuilder();
132 builder.append(boolValue);
133 builder.append(doubleValue);
134 builder.append(intValue);
135 builder.append(stringValue);
136 builder.append(enumValue);
137 builder.append(expression);
138 return builder.toHashCode();
139 }
140
141 public JsonObject toJson() {
142 JsonObject jsonObject = new JsonObject();
143 if (boolValue != null) {
144 jsonObject.addProperty("boolValue", boolValue);
145 }
146 if (doubleValue != null) {
147 jsonObject.addProperty("doubleValue", doubleValue);
148 }
149 if (intValue != null) {
150 jsonObject.addProperty("intValue", intValue);
151 }
152 if (stringValue != null) {
153 jsonObject.addProperty("stringValue", stringValue);
154 }
155 if (enumValue != null) {
156 jsonObject.add("enumValue", enumValue.toJson());
157 }
158 if (expression != null) {
159 jsonObject.addProperty("expression", expression);
160 }
161 return jsonObject;
162 }
163
164 @Override
165 public String toString() {
166 StringBuilder builder = new StringBuilder();
167 builder.append("[");
168 builder.append("boolValue=");
169 builder.append(boolValue + ", ");
170 builder.append("doubleValue=");
171 builder.append(doubleValue + ", ");
172 builder.append("intValue=");
173 builder.append(intValue + ", ");
174 builder.append("stringValue=");
175 builder.append(stringValue + ", ");
176 builder.append("enumValue=");
177 builder.append(enumValue + ", ");
178 builder.append("expression=");
179 builder.append(expression);
180 builder.append("]");
181 return builder.toString();
182 }
183
184}
static FlutterWidgetPropertyValueEnumItem fromJson(JsonObject jsonObject)
static List< FlutterWidgetPropertyValue > fromJsonArray(JsonArray jsonArray)
FlutterWidgetPropertyValue(Boolean boolValue, Double doubleValue, Integer intValue, String stringValue, FlutterWidgetPropertyValueEnumItem enumValue, String expression)
static FlutterWidgetPropertyValue fromJson(JsonObject jsonObject)