Flutter Engine
The Flutter Engine
MessageAction.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 action associated with a message that the server is requesting the client to display to the
28 * user.
29 *
30 * @coverage dart.server.generated.types
31 */
32@SuppressWarnings("unused")
33public class MessageAction {
34
35 public static final MessageAction[] EMPTY_ARRAY = new MessageAction[0];
36
37 public static final List<MessageAction> EMPTY_LIST = Lists.newArrayList();
38
39 /**
40 * The label of the button to be displayed, and the value to be returned to the server if the
41 * button is clicked.
42 */
43 private final String label;
44
45 /**
46 * Constructor for {@link MessageAction}.
47 */
48 public MessageAction(String label) {
49 this.label = label;
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (obj instanceof MessageAction) {
55 MessageAction other = (MessageAction) obj;
56 return
57 ObjectUtilities.equals(other.label, label);
58 }
59 return false;
60 }
61
62 public static MessageAction fromJson(JsonObject jsonObject) {
63 String label = jsonObject.get("label").getAsString();
64 return new MessageAction(label);
65 }
66
67 public static List<MessageAction> fromJsonArray(JsonArray jsonArray) {
68 if (jsonArray == null) {
69 return EMPTY_LIST;
70 }
71 ArrayList<MessageAction> list = new ArrayList<MessageAction>(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
79 /**
80 * The label of the button to be displayed, and the value to be returned to the server if the
81 * button is clicked.
82 */
83 public String getLabel() {
84 return label;
85 }
86
87 @Override
88 public int hashCode() {
89 HashCodeBuilder builder = new HashCodeBuilder();
90 builder.append(label);
91 return builder.toHashCode();
92 }
93
94 public JsonObject toJson() {
95 JsonObject jsonObject = new JsonObject();
96 jsonObject.addProperty("label", label);
97 return jsonObject;
98 }
99
100 @Override
101 public String toString() {
102 StringBuilder builder = new StringBuilder();
103 builder.append("[");
104 builder.append("label=");
105 builder.append(label);
106 builder.append("]");
107 return builder.toString();
108 }
109
110}
static List< MessageAction > fromJsonArray(JsonArray jsonArray)
static MessageAction fromJson(JsonObject jsonObject)