Flutter Engine
The Flutter Engine
FlutterWidgetPropertyEditor.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 editor for a property of a Flutter widget.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final FlutterWidgetPropertyEditor[] EMPTY_ARRAY = new FlutterWidgetPropertyEditor[0];
35
36 public static final List<FlutterWidgetPropertyEditor> EMPTY_LIST = Lists.newArrayList();
37
38 private final String kind;
39
40 private final List<FlutterWidgetPropertyValueEnumItem> enumItems;
41
42 /**
43 * Constructor for {@link FlutterWidgetPropertyEditor}.
44 */
46 this.kind = kind;
47 this.enumItems = enumItems;
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (obj instanceof FlutterWidgetPropertyEditor) {
54 return
55 ObjectUtilities.equals(other.kind, kind) &&
56 ObjectUtilities.equals(other.enumItems, enumItems);
57 }
58 return false;
59 }
60
61 public static FlutterWidgetPropertyEditor fromJson(JsonObject jsonObject) {
62 String kind = jsonObject.get("kind").getAsString();
63 List<FlutterWidgetPropertyValueEnumItem> enumItems = jsonObject.get("enumItems") == null ? null : FlutterWidgetPropertyValueEnumItem.fromJsonArray(jsonObject.get("enumItems").getAsJsonArray());
64 return new FlutterWidgetPropertyEditor(kind, enumItems);
65 }
66
67 public static List<FlutterWidgetPropertyEditor> fromJsonArray(JsonArray jsonArray) {
68 if (jsonArray == null) {
69 return EMPTY_LIST;
70 }
71 ArrayList<FlutterWidgetPropertyEditor> list = new ArrayList<FlutterWidgetPropertyEditor>(jsonArray.size());
72 Iterator<JsonElement> iterator = jsonArray.iterator();
73 while (iterator.hasNext()) {
74 list.add(fromJson(iterator.next().getAsJsonObject()));
75 }
76 return list;
77 }
78
80 return enumItems;
81 }
82
83 public String getKind() {
84 return kind;
85 }
86
87 @Override
88 public int hashCode() {
89 HashCodeBuilder builder = new HashCodeBuilder();
90 builder.append(kind);
91 builder.append(enumItems);
92 return builder.toHashCode();
93 }
94
95 public JsonObject toJson() {
96 JsonObject jsonObject = new JsonObject();
97 jsonObject.addProperty("kind", kind);
98 if (enumItems != null) {
99 JsonArray jsonArrayEnumItems = new JsonArray();
100 for (FlutterWidgetPropertyValueEnumItem elt : enumItems) {
101 jsonArrayEnumItems.add(elt.toJson());
102 }
103 jsonObject.add("enumItems", jsonArrayEnumItems);
104 }
105 return jsonObject;
106 }
107
108 @Override
109 public String toString() {
110 StringBuilder builder = new StringBuilder();
111 builder.append("[");
112 builder.append("kind=");
113 builder.append(kind + ", ");
114 builder.append("enumItems=");
115 builder.append(StringUtils.join(enumItems, ", "));
116 builder.append("]");
117 return builder.toString();
118 }
119
120}
FlutterWidgetPropertyEditor(String kind, List< FlutterWidgetPropertyValueEnumItem > enumItems)
static FlutterWidgetPropertyEditor fromJson(JsonObject jsonObject)
static List< FlutterWidgetPropertyEditor > fromJsonArray(JsonArray jsonArray)
static List< FlutterWidgetPropertyValueEnumItem > fromJsonArray(JsonArray jsonArray)