Flutter Engine
The Flutter Engine
InlineLocalVariableFeedback.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 InlineLocalVariableFeedback[] EMPTY_ARRAY = new InlineLocalVariableFeedback[0];
33
34 public static final List<InlineLocalVariableFeedback> EMPTY_LIST = Lists.newArrayList();
35
36 /**
37 * The name of the variable being inlined.
38 */
39 private final String name;
40
41 /**
42 * The number of times the variable occurs.
43 */
44 private final int occurrences;
45
46 /**
47 * Constructor for {@link InlineLocalVariableFeedback}.
48 */
49 public InlineLocalVariableFeedback(String name, int occurrences) {
50 this.name = name;
51 this.occurrences = occurrences;
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (obj instanceof InlineLocalVariableFeedback) {
58 return
59 ObjectUtilities.equals(other.name, name) &&
60 other.occurrences == occurrences;
61 }
62 return false;
63 }
64
65 public static InlineLocalVariableFeedback fromJson(JsonObject jsonObject) {
66 String name = jsonObject.get("name").getAsString();
67 int occurrences = jsonObject.get("occurrences").getAsInt();
68 return new InlineLocalVariableFeedback(name, occurrences);
69 }
70
71 public static List<InlineLocalVariableFeedback> fromJsonArray(JsonArray jsonArray) {
72 if (jsonArray == null) {
73 return EMPTY_LIST;
74 }
75 ArrayList<InlineLocalVariableFeedback> list = new ArrayList<InlineLocalVariableFeedback>(jsonArray.size());
76 Iterator<JsonElement> iterator = jsonArray.iterator();
77 while (iterator.hasNext()) {
78 list.add(fromJson(iterator.next().getAsJsonObject()));
79 }
80 return list;
81 }
82
83 /**
84 * The name of the variable being inlined.
85 */
86 public String getName() {
87 return name;
88 }
89
90 /**
91 * The number of times the variable occurs.
92 */
93 public int getOccurrences() {
94 return occurrences;
95 }
96
97 @Override
98 public int hashCode() {
99 HashCodeBuilder builder = new HashCodeBuilder();
100 builder.append(name);
101 builder.append(occurrences);
102 return builder.toHashCode();
103 }
104
105 public JsonObject toJson() {
106 JsonObject jsonObject = new JsonObject();
107 jsonObject.addProperty("name", name);
108 jsonObject.addProperty("occurrences", occurrences);
109 return jsonObject;
110 }
111
112 @Override
113 public String toString() {
114 StringBuilder builder = new StringBuilder();
115 builder.append("[");
116 builder.append("name=");
117 builder.append(name + ", ");
118 builder.append("occurrences=");
119 builder.append(occurrences);
120 builder.append("]");
121 return builder.toString();
122 }
123
124}
static List< InlineLocalVariableFeedback > fromJsonArray(JsonArray jsonArray)
static InlineLocalVariableFeedback fromJson(JsonObject jsonObject)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32