Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ImportedElementSet.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 * The set of top-level elements encoded as pairs of the defining library URI and the name, and
28 * stored in the parallel lists elementUris and elementNames.
29 *
30 * @coverage dart.server.generated.types
31 */
32@SuppressWarnings("unused")
33public class ImportedElementSet {
34
35 public static final ImportedElementSet[] EMPTY_ARRAY = new ImportedElementSet[0];
36
37 public static final List<ImportedElementSet> EMPTY_LIST = Lists.newArrayList();
38
39 /**
40 * The list of unique strings in this object.
41 */
42 private final List<String> strings;
43
44 /**
45 * The library URI part of the element. It is an index in the strings field.
46 */
47 private final int[] uris;
48
49 /**
50 * The name part of a the element. It is an index in the strings field.
51 */
52 private final int[] names;
53
54 /**
55 * Constructor for {@link ImportedElementSet}.
56 */
57 public ImportedElementSet(List<String> strings, int[] uris, int[] names) {
58 this.strings = strings;
59 this.uris = uris;
60 this.names = names;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (obj instanceof ImportedElementSet) {
67 return
68 ObjectUtilities.equals(other.strings, strings) &&
69 Arrays.equals(other.uris, uris) &&
70 Arrays.equals(other.names, names);
71 }
72 return false;
73 }
74
75 public static ImportedElementSet fromJson(JsonObject jsonObject) {
76 List<String> strings = JsonUtilities.decodeStringList(jsonObject.get("strings").getAsJsonArray());
77 int[] uris = JsonUtilities.decodeIntArray(jsonObject.get("uris").getAsJsonArray());
78 int[] names = JsonUtilities.decodeIntArray(jsonObject.get("names").getAsJsonArray());
79 return new ImportedElementSet(strings, uris, names);
80 }
81
82 public static List<ImportedElementSet> fromJsonArray(JsonArray jsonArray) {
83 if (jsonArray == null) {
84 return EMPTY_LIST;
85 }
86 ArrayList<ImportedElementSet> list = new ArrayList<ImportedElementSet>(jsonArray.size());
87 Iterator<JsonElement> iterator = jsonArray.iterator();
88 while (iterator.hasNext()) {
89 list.add(fromJson(iterator.next().getAsJsonObject()));
90 }
91 return list;
92 }
93
94 /**
95 * The name part of a the element. It is an index in the strings field.
96 */
97 public int[] getNames() {
98 return names;
99 }
100
101 /**
102 * The list of unique strings in this object.
103 */
105 return strings;
106 }
107
108 /**
109 * The library URI part of the element. It is an index in the strings field.
110 */
111 public int[] getUris() {
112 return uris;
113 }
114
115 @Override
116 public int hashCode() {
117 HashCodeBuilder builder = new HashCodeBuilder();
118 builder.append(strings);
119 builder.append(uris);
120 builder.append(names);
121 return builder.toHashCode();
122 }
123
124 public JsonObject toJson() {
125 JsonObject jsonObject = new JsonObject();
126 JsonArray jsonArrayStrings = new JsonArray();
127 for (String elt : strings) {
128 jsonArrayStrings.add(new JsonPrimitive(elt));
129 }
130 jsonObject.add("strings", jsonArrayStrings);
131 JsonArray jsonArrayUris = new JsonArray();
132 for (int elt : uris) {
133 jsonArrayUris.add(new JsonPrimitive(elt));
134 }
135 jsonObject.add("uris", jsonArrayUris);
136 JsonArray jsonArrayNames = new JsonArray();
137 for (int elt : names) {
138 jsonArrayNames.add(new JsonPrimitive(elt));
139 }
140 jsonObject.add("names", jsonArrayNames);
141 return jsonObject;
142 }
143
144 @Override
145 public String toString() {
146 StringBuilder builder = new StringBuilder();
147 builder.append("[");
148 builder.append("strings=");
149 builder.append(StringUtils.join(strings, ", ") + ", ");
150 builder.append("uris=");
151 builder.append(StringUtils.join(uris, ", ") + ", ");
152 builder.append("names=");
153 builder.append(StringUtils.join(names, ", "));
154 builder.append("]");
155 return builder.toString();
156 }
157
158}
static ImportedElementSet fromJson(JsonObject jsonObject)
ImportedElementSet(List< String > strings, int[] uris, int[] names)
static List< ImportedElementSet > fromJsonArray(JsonArray jsonArray)