OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015, the Dart project authors. |
| 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. |
| 13 * |
| 14 * This file has been automatically generated. Please do not edit it manually. |
| 15 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generat
e_files". |
| 16 */ |
| 17 package org.dartlang.analysis.server.protocol; |
| 18 |
| 19 import java.util.Arrays; |
| 20 import java.util.List; |
| 21 import java.util.Map; |
| 22 import com.google.common.collect.Lists; |
| 23 import com.google.dart.server.utilities.general.JsonUtilities; |
| 24 import com.google.dart.server.utilities.general.ObjectUtilities; |
| 25 import com.google.gson.JsonArray; |
| 26 import com.google.gson.JsonElement; |
| 27 import com.google.gson.JsonObject; |
| 28 import com.google.gson.JsonPrimitive; |
| 29 import org.apache.commons.lang3.builder.HashCodeBuilder; |
| 30 import java.util.ArrayList; |
| 31 import java.util.Iterator; |
| 32 import org.apache.commons.lang3.StringUtils; |
| 33 |
| 34 /** |
| 35 * A description of the elements that are referenced in a region of a file that
come from a single |
| 36 * imported library. |
| 37 * |
| 38 * @coverage dart.server.generated.types |
| 39 */ |
| 40 @SuppressWarnings("unused") |
| 41 public class ImportedElements { |
| 42 |
| 43 public static final ImportedElements[] EMPTY_ARRAY = new ImportedElements[0]; |
| 44 |
| 45 public static final List<ImportedElements> EMPTY_LIST = Lists.newArrayList(); |
| 46 |
| 47 /** |
| 48 * The absolute and normalized path of the file containing the library. |
| 49 */ |
| 50 private final String path; |
| 51 |
| 52 /** |
| 53 * The URI that was used when importing the library into the original source. |
| 54 */ |
| 55 private final String uri; |
| 56 |
| 57 /** |
| 58 * The prefix that was used when importing the library into the original sourc
e. |
| 59 */ |
| 60 private final String prefix; |
| 61 |
| 62 /** |
| 63 * The names of the elements imported from the library. |
| 64 */ |
| 65 private final List<String> elements; |
| 66 |
| 67 /** |
| 68 * Constructor for {@link ImportedElements}. |
| 69 */ |
| 70 public ImportedElements(String path, String uri, String prefix, List<String> e
lements) { |
| 71 this.path = path; |
| 72 this.uri = uri; |
| 73 this.prefix = prefix; |
| 74 this.elements = elements; |
| 75 } |
| 76 |
| 77 @Override |
| 78 public boolean equals(Object obj) { |
| 79 if (obj instanceof ImportedElements) { |
| 80 ImportedElements other = (ImportedElements) obj; |
| 81 return |
| 82 ObjectUtilities.equals(other.path, path) && |
| 83 ObjectUtilities.equals(other.uri, uri) && |
| 84 ObjectUtilities.equals(other.prefix, prefix) && |
| 85 ObjectUtilities.equals(other.elements, elements); |
| 86 } |
| 87 return false; |
| 88 } |
| 89 |
| 90 public static ImportedElements fromJson(JsonObject jsonObject) { |
| 91 String path = jsonObject.get("path").getAsString(); |
| 92 String uri = jsonObject.get("uri").getAsString(); |
| 93 String prefix = jsonObject.get("prefix").getAsString(); |
| 94 List<String> elements = JsonUtilities.decodeStringList(jsonObject.get("eleme
nts").getAsJsonArray()); |
| 95 return new ImportedElements(path, uri, prefix, elements); |
| 96 } |
| 97 |
| 98 public static List<ImportedElements> fromJsonArray(JsonArray jsonArray) { |
| 99 if (jsonArray == null) { |
| 100 return EMPTY_LIST; |
| 101 } |
| 102 ArrayList<ImportedElements> list = new ArrayList<ImportedElements>(jsonArray
.size()); |
| 103 Iterator<JsonElement> iterator = jsonArray.iterator(); |
| 104 while (iterator.hasNext()) { |
| 105 list.add(fromJson(iterator.next().getAsJsonObject())); |
| 106 } |
| 107 return list; |
| 108 } |
| 109 |
| 110 /** |
| 111 * The names of the elements imported from the library. |
| 112 */ |
| 113 public List<String> getElements() { |
| 114 return elements; |
| 115 } |
| 116 |
| 117 /** |
| 118 * The absolute and normalized path of the file containing the library. |
| 119 */ |
| 120 public String getPath() { |
| 121 return path; |
| 122 } |
| 123 |
| 124 /** |
| 125 * The prefix that was used when importing the library into the original sourc
e. |
| 126 */ |
| 127 public String getPrefix() { |
| 128 return prefix; |
| 129 } |
| 130 |
| 131 /** |
| 132 * The URI that was used when importing the library into the original source. |
| 133 */ |
| 134 public String getUri() { |
| 135 return uri; |
| 136 } |
| 137 |
| 138 @Override |
| 139 public int hashCode() { |
| 140 HashCodeBuilder builder = new HashCodeBuilder(); |
| 141 builder.append(path); |
| 142 builder.append(uri); |
| 143 builder.append(prefix); |
| 144 builder.append(elements); |
| 145 return builder.toHashCode(); |
| 146 } |
| 147 |
| 148 public JsonObject toJson() { |
| 149 JsonObject jsonObject = new JsonObject(); |
| 150 jsonObject.addProperty("path", path); |
| 151 jsonObject.addProperty("uri", uri); |
| 152 jsonObject.addProperty("prefix", prefix); |
| 153 JsonArray jsonArrayElements = new JsonArray(); |
| 154 for (String elt : elements) { |
| 155 jsonArrayElements.add(new JsonPrimitive(elt)); |
| 156 } |
| 157 jsonObject.add("elements", jsonArrayElements); |
| 158 return jsonObject; |
| 159 } |
| 160 |
| 161 @Override |
| 162 public String toString() { |
| 163 StringBuilder builder = new StringBuilder(); |
| 164 builder.append("["); |
| 165 builder.append("path="); |
| 166 builder.append(path + ", "); |
| 167 builder.append("uri="); |
| 168 builder.append(uri + ", "); |
| 169 builder.append("prefix="); |
| 170 builder.append(prefix + ", "); |
| 171 builder.append("elements="); |
| 172 builder.append(StringUtils.join(elements, ", ")); |
| 173 builder.append("]"); |
| 174 return builder.toString(); |
| 175 } |
| 176 |
| 177 } |
OLD | NEW |