Flutter Engine
The Flutter Engine
ExtractMethodOptions.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 * @coverage dart.server.generated.types
28 */
29@SuppressWarnings("unused")
31
32 public static final ExtractMethodOptions[] EMPTY_ARRAY = new ExtractMethodOptions[0];
33
34 public static final List<ExtractMethodOptions> EMPTY_LIST = Lists.newArrayList();
35
36 /**
37 * The return type that should be defined for the method.
38 */
39 private String returnType;
40
41 /**
42 * True if a getter should be created rather than a method. It is an error if this field is true
43 * and the list of parameters is non-empty.
44 */
45 private boolean createGetter;
46
47 /**
48 * The name that the method should be given.
49 */
50 private String name;
51
52 /**
53 * The parameters that should be defined for the method.
54 *
55 * It is an error if a REQUIRED or NAMED parameter follows a POSITIONAL parameter. It is an error
56 * if a REQUIRED or POSITIONAL parameter follows a NAMED parameter.
57 *
58 * - To change the order and/or update proposed parameters, add parameters with the same
59 * identifiers as proposed.
60 * - To add new parameters, omit their identifier.
61 * - To remove some parameters, omit them in this list.
62 */
63 private List<RefactoringMethodParameter> parameters;
64
65 /**
66 * True if all occurrences of the expression or statements should be replaced by an invocation of
67 * the method. The expression or statements used to initiate the refactoring will always be
68 * replaced.
69 */
70 private boolean extractAll;
71
72 /**
73 * Constructor for {@link ExtractMethodOptions}.
74 */
75 public ExtractMethodOptions(String returnType, boolean createGetter, String name, List<RefactoringMethodParameter> parameters, boolean extractAll) {
76 this.returnType = returnType;
77 this.createGetter = createGetter;
78 this.name = name;
79 this.parameters = parameters;
80 this.extractAll = extractAll;
81 }
82
83 @Override
84 public boolean equals(Object obj) {
85 if (obj instanceof ExtractMethodOptions) {
87 return
88 ObjectUtilities.equals(other.returnType, returnType) &&
89 other.createGetter == createGetter &&
90 ObjectUtilities.equals(other.name, name) &&
91 ObjectUtilities.equals(other.parameters, parameters) &&
92 other.extractAll == extractAll;
93 }
94 return false;
95 }
96
97 public static ExtractMethodOptions fromJson(JsonObject jsonObject) {
98 String returnType = jsonObject.get("returnType").getAsString();
99 boolean createGetter = jsonObject.get("createGetter").getAsBoolean();
100 String name = jsonObject.get("name").getAsString();
101 List<RefactoringMethodParameter> parameters = RefactoringMethodParameter.fromJsonArray(jsonObject.get("parameters").getAsJsonArray());
102 boolean extractAll = jsonObject.get("extractAll").getAsBoolean();
103 return new ExtractMethodOptions(returnType, createGetter, name, parameters, extractAll);
104 }
105
106 public static List<ExtractMethodOptions> fromJsonArray(JsonArray jsonArray) {
107 if (jsonArray == null) {
108 return EMPTY_LIST;
109 }
110 ArrayList<ExtractMethodOptions> list = new ArrayList<ExtractMethodOptions>(jsonArray.size());
111 Iterator<JsonElement> iterator = jsonArray.iterator();
112 while (iterator.hasNext()) {
113 list.add(fromJson(iterator.next().getAsJsonObject()));
114 }
115 return list;
116 }
117
118 /**
119 * True if a getter should be created rather than a method. It is an error if this field is true
120 * and the list of parameters is non-empty.
121 */
122 public boolean createGetter() {
123 return createGetter;
124 }
125
126 /**
127 * True if all occurrences of the expression or statements should be replaced by an invocation of
128 * the method. The expression or statements used to initiate the refactoring will always be
129 * replaced.
130 */
131 public boolean extractAll() {
132 return extractAll;
133 }
134
135 /**
136 * The name that the method should be given.
137 */
138 public String getName() {
139 return name;
140 }
141
142 /**
143 * The parameters that should be defined for the method.
144 *
145 * It is an error if a REQUIRED or NAMED parameter follows a POSITIONAL parameter. It is an error
146 * if a REQUIRED or POSITIONAL parameter follows a NAMED parameter.
147 *
148 * - To change the order and/or update proposed parameters, add parameters with the same
149 * identifiers as proposed.
150 * - To add new parameters, omit their identifier.
151 * - To remove some parameters, omit them in this list.
152 */
154 return parameters;
155 }
156
157 /**
158 * The return type that should be defined for the method.
159 */
160 public String getReturnType() {
161 return returnType;
162 }
163
164 @Override
165 public int hashCode() {
166 HashCodeBuilder builder = new HashCodeBuilder();
167 builder.append(returnType);
168 builder.append(createGetter);
169 builder.append(name);
170 builder.append(parameters);
171 builder.append(extractAll);
172 return builder.toHashCode();
173 }
174
175 /**
176 * True if a getter should be created rather than a method. It is an error if this field is true
177 * and the list of parameters is non-empty.
178 */
179 public void setCreateGetter(boolean createGetter) {
180 this.createGetter = createGetter;
181 }
182
183 /**
184 * True if all occurrences of the expression or statements should be replaced by an invocation of
185 * the method. The expression or statements used to initiate the refactoring will always be
186 * replaced.
187 */
188 public void setExtractAll(boolean extractAll) {
189 this.extractAll = extractAll;
190 }
191
192 /**
193 * The name that the method should be given.
194 */
195 public void setName(String name) {
196 this.name = name;
197 }
198
199 /**
200 * The parameters that should be defined for the method.
201 *
202 * It is an error if a REQUIRED or NAMED parameter follows a POSITIONAL parameter. It is an error
203 * if a REQUIRED or POSITIONAL parameter follows a NAMED parameter.
204 *
205 * - To change the order and/or update proposed parameters, add parameters with the same
206 * identifiers as proposed.
207 * - To add new parameters, omit their identifier.
208 * - To remove some parameters, omit them in this list.
209 */
211 this.parameters = parameters;
212 }
213
214 /**
215 * The return type that should be defined for the method.
216 */
217 public void setReturnType(String returnType) {
218 this.returnType = returnType;
219 }
220
221 public JsonObject toJson() {
222 JsonObject jsonObject = new JsonObject();
223 jsonObject.addProperty("returnType", returnType);
224 jsonObject.addProperty("createGetter", createGetter);
225 jsonObject.addProperty("name", name);
226 JsonArray jsonArrayParameters = new JsonArray();
227 for (RefactoringMethodParameter elt : parameters) {
228 jsonArrayParameters.add(elt.toJson());
229 }
230 jsonObject.add("parameters", jsonArrayParameters);
231 jsonObject.addProperty("extractAll", extractAll);
232 return jsonObject;
233 }
234
235 @Override
236 public String toString() {
237 StringBuilder builder = new StringBuilder();
238 builder.append("[");
239 builder.append("returnType=");
240 builder.append(returnType + ", ");
241 builder.append("createGetter=");
242 builder.append(createGetter + ", ");
243 builder.append("name=");
244 builder.append(name + ", ");
245 builder.append("parameters=");
246 builder.append(StringUtils.join(parameters, ", ") + ", ");
247 builder.append("extractAll=");
248 builder.append(extractAll);
249 builder.append("]");
250 return builder.toString();
251 }
252
253}
ExtractMethodOptions(String returnType, boolean createGetter, String name, List< RefactoringMethodParameter > parameters, boolean extractAll)
static ExtractMethodOptions fromJson(JsonObject jsonObject)
void setParameters(List< RefactoringMethodParameter > parameters)
static List< ExtractMethodOptions > fromJsonArray(JsonArray jsonArray)
static List< RefactoringMethodParameter > fromJsonArray(JsonArray jsonArray)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32