Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ExtractLocalVariableOptions.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 ExtractLocalVariableOptions[] EMPTY_ARRAY = new ExtractLocalVariableOptions[0];
33
34 public static final List<ExtractLocalVariableOptions> EMPTY_LIST = Lists.newArrayList();
35
36 /**
37 * The name that the local variable should be given.
38 */
39 private String name;
40
41 /**
42 * True if all occurrences of the expression within the scope in which the variable will be defined
43 * should be replaced by a reference to the local variable. The expression used to initiate the
44 * refactoring will always be replaced.
45 */
46 private boolean extractAll;
47
48 /**
49 * Constructor for {@link ExtractLocalVariableOptions}.
50 */
51 public ExtractLocalVariableOptions(String name, boolean extractAll) {
52 this.name = name;
53 this.extractAll = extractAll;
54 }
55
56 @Override
57 public boolean equals(Object obj) {
58 if (obj instanceof ExtractLocalVariableOptions) {
60 return
61 ObjectUtilities.equals(other.name, name) &&
62 other.extractAll == extractAll;
63 }
64 return false;
65 }
66
67 public static ExtractLocalVariableOptions fromJson(JsonObject jsonObject) {
68 String name = jsonObject.get("name").getAsString();
69 boolean extractAll = jsonObject.get("extractAll").getAsBoolean();
70 return new ExtractLocalVariableOptions(name, extractAll);
71 }
72
73 public static List<ExtractLocalVariableOptions> fromJsonArray(JsonArray jsonArray) {
74 if (jsonArray == null) {
75 return EMPTY_LIST;
76 }
77 ArrayList<ExtractLocalVariableOptions> list = new ArrayList<ExtractLocalVariableOptions>(jsonArray.size());
78 Iterator<JsonElement> iterator = jsonArray.iterator();
79 while (iterator.hasNext()) {
80 list.add(fromJson(iterator.next().getAsJsonObject()));
81 }
82 return list;
83 }
84
85 /**
86 * True if all occurrences of the expression within the scope in which the variable will be defined
87 * should be replaced by a reference to the local variable. The expression used to initiate the
88 * refactoring will always be replaced.
89 */
90 public boolean extractAll() {
91 return extractAll;
92 }
93
94 /**
95 * The name that the local variable should be given.
96 */
97 public String getName() {
98 return name;
99 }
100
101 @Override
102 public int hashCode() {
103 HashCodeBuilder builder = new HashCodeBuilder();
104 builder.append(name);
105 builder.append(extractAll);
106 return builder.toHashCode();
107 }
108
109 /**
110 * True if all occurrences of the expression within the scope in which the variable will be defined
111 * should be replaced by a reference to the local variable. The expression used to initiate the
112 * refactoring will always be replaced.
113 */
114 public void setExtractAll(boolean extractAll) {
115 this.extractAll = extractAll;
116 }
117
118 /**
119 * The name that the local variable should be given.
120 */
121 public void setName(String name) {
122 this.name = name;
123 }
124
125 public JsonObject toJson() {
126 JsonObject jsonObject = new JsonObject();
127 jsonObject.addProperty("name", name);
128 jsonObject.addProperty("extractAll", extractAll);
129 return jsonObject;
130 }
131
132 @Override
133 public String toString() {
134 StringBuilder builder = new StringBuilder();
135 builder.append("[");
136 builder.append("name=");
137 builder.append(name + ", ");
138 builder.append("extractAll=");
139 builder.append(extractAll);
140 builder.append("]");
141 return builder.toString();
142 }
143
144}
static List< ExtractLocalVariableOptions > fromJsonArray(JsonArray jsonArray)
static ExtractLocalVariableOptions fromJson(JsonObject jsonObject)
const char * name
Definition fuchsia.cc:50