Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
LinkedEditSuggestion.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 suggestion of a value that could be used to replace all of the linked edit regions in a
28 * LinkedEditGroup.
29 *
30 * @coverage dart.server.generated.types
31 */
32@SuppressWarnings("unused")
34
35 public static final LinkedEditSuggestion[] EMPTY_ARRAY = new LinkedEditSuggestion[0];
36
37 public static final List<LinkedEditSuggestion> EMPTY_LIST = Lists.newArrayList();
38
39 /**
40 * The value that could be used to replace all of the linked edit regions.
41 */
42 private final String value;
43
44 /**
45 * The kind of value being proposed.
46 */
47 private final String kind;
48
49 /**
50 * Constructor for {@link LinkedEditSuggestion}.
51 */
52 public LinkedEditSuggestion(String value, String kind) {
53 this.value = value;
54 this.kind = kind;
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (obj instanceof LinkedEditSuggestion) {
61 return
62 ObjectUtilities.equals(other.value, value) &&
63 ObjectUtilities.equals(other.kind, kind);
64 }
65 return false;
66 }
67
68 public static LinkedEditSuggestion fromJson(JsonObject jsonObject) {
69 String value = jsonObject.get("value").getAsString();
70 String kind = jsonObject.get("kind").getAsString();
71 return new LinkedEditSuggestion(value, kind);
72 }
73
74 public static List<LinkedEditSuggestion> fromJsonArray(JsonArray jsonArray) {
75 if (jsonArray == null) {
76 return EMPTY_LIST;
77 }
78 ArrayList<LinkedEditSuggestion> list = new ArrayList<LinkedEditSuggestion>(jsonArray.size());
79 Iterator<JsonElement> iterator = jsonArray.iterator();
80 while (iterator.hasNext()) {
81 list.add(fromJson(iterator.next().getAsJsonObject()));
82 }
83 return list;
84 }
85
86 /**
87 * The kind of value being proposed.
88 */
89 public String getKind() {
90 return kind;
91 }
92
93 /**
94 * The value that could be used to replace all of the linked edit regions.
95 */
96 public String getValue() {
97 return value;
98 }
99
100 @Override
101 public int hashCode() {
102 HashCodeBuilder builder = new HashCodeBuilder();
103 builder.append(value);
104 builder.append(kind);
105 return builder.toHashCode();
106 }
107
108 public JsonObject toJson() {
109 JsonObject jsonObject = new JsonObject();
110 jsonObject.addProperty("value", value);
111 jsonObject.addProperty("kind", kind);
112 return jsonObject;
113 }
114
115 @Override
116 public String toString() {
117 StringBuilder builder = new StringBuilder();
118 builder.append("[");
119 builder.append("value=");
120 builder.append(value + ", ");
121 builder.append("kind=");
122 builder.append(kind);
123 builder.append("]");
124 return builder.toString();
125 }
126
127}
static LinkedEditSuggestion fromJson(JsonObject jsonObject)
static List< LinkedEditSuggestion > fromJsonArray(JsonArray jsonArray)
uint8_t value