Flutter Engine
The Flutter Engine
ImportedElements.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 description of the elements that are referenced in a region of a file that come from a single
28 * imported library.
29 *
30 * @coverage dart.server.generated.types
31 */
32@SuppressWarnings("unused")
33public class ImportedElements {
34
35 public static final ImportedElements[] EMPTY_ARRAY = new ImportedElements[0];
36
37 public static final List<ImportedElements> EMPTY_LIST = Lists.newArrayList();
38
39 /**
40 * The absolute and normalized path of the file containing the library.
41 */
42 private final String path;
43
44 /**
45 * The prefix that was used when importing the library into the original source.
46 */
47 private final String prefix;
48
49 /**
50 * The names of the elements imported from the library.
51 */
52 private final List<String> elements;
53
54 /**
55 * Constructor for {@link ImportedElements}.
56 */
57 public ImportedElements(String path, String prefix, List<String> elements) {
58 this.path = path;
59 this.prefix = prefix;
60 this.elements = elements;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (obj instanceof ImportedElements) {
67 return
68 ObjectUtilities.equals(other.path, path) &&
69 ObjectUtilities.equals(other.prefix, prefix) &&
70 ObjectUtilities.equals(other.elements, elements);
71 }
72 return false;
73 }
74
75 public static ImportedElements fromJson(JsonObject jsonObject) {
76 String path = jsonObject.get("path").getAsString();
77 String prefix = jsonObject.get("prefix").getAsString();
78 List<String> elements = JsonUtilities.decodeStringList(jsonObject.get("elements").getAsJsonArray());
79 return new ImportedElements(path, prefix, elements);
80 }
81
82 public static List<ImportedElements> fromJsonArray(JsonArray jsonArray) {
83 if (jsonArray == null) {
84 return EMPTY_LIST;
85 }
86 ArrayList<ImportedElements> list = new ArrayList<ImportedElements>(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 names of the elements imported from the library.
96 */
98 return elements;
99 }
100
101 /**
102 * The absolute and normalized path of the file containing the library.
103 */
104 public String getPath() {
105 return path;
106 }
107
108 /**
109 * The prefix that was used when importing the library into the original source.
110 */
111 public String getPrefix() {
112 return prefix;
113 }
114
115 @Override
116 public int hashCode() {
117 HashCodeBuilder builder = new HashCodeBuilder();
118 builder.append(path);
119 builder.append(prefix);
120 builder.append(elements);
121 return builder.toHashCode();
122 }
123
124 public JsonObject toJson() {
125 JsonObject jsonObject = new JsonObject();
126 jsonObject.addProperty("path", path);
127 jsonObject.addProperty("prefix", prefix);
128 JsonArray jsonArrayElements = new JsonArray();
129 for (String elt : elements) {
130 jsonArrayElements.add(new JsonPrimitive(elt));
131 }
132 jsonObject.add("elements", jsonArrayElements);
133 return jsonObject;
134 }
135
136 @Override
137 public String toString() {
138 StringBuilder builder = new StringBuilder();
139 builder.append("[");
140 builder.append("path=");
141 builder.append(path + ", ");
142 builder.append("prefix=");
143 builder.append(prefix + ", ");
144 builder.append("elements=");
145 builder.append(StringUtils.join(elements, ", "));
146 builder.append("]");
147 return builder.toString();
148 }
149
150}
static ImportedElements fromJson(JsonObject jsonObject)
static List< ImportedElements > fromJsonArray(JsonArray jsonArray)
ImportedElements(String path, String prefix, List< String > elements)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57