Flutter Engine
The Flutter Engine
AddContentOverlay.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 directive to begin overlaying the contents of a file. The supplied content will be used for
28 * analysis in place of the file contents in the filesystem.
29 *
30 * If this directive is used on a file that already has a file content overlay, the old overlay is
31 * discarded and replaced with the new one.
32 *
33 * @coverage dart.server.generated.types
34 */
35@SuppressWarnings("unused")
36public class AddContentOverlay {
37
38 public static final AddContentOverlay[] EMPTY_ARRAY = new AddContentOverlay[0];
39
40 public static final List<AddContentOverlay> EMPTY_LIST = Lists.newArrayList();
41
42 private final String type;
43
44 /**
45 * The new content of the file.
46 */
47 private final String content;
48
49 /**
50 * Constructor for {@link AddContentOverlay}.
51 */
52 public AddContentOverlay(String content) {
53 this.type = "add";
54 this.content = content;
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (obj instanceof AddContentOverlay) {
61 return
62 ObjectUtilities.equals(other.type, type) &&
63 ObjectUtilities.equals(other.content, content);
64 }
65 return false;
66 }
67
68 public static AddContentOverlay fromJson(JsonObject jsonObject) {
69 String type = jsonObject.get("type").getAsString();
70 String content = jsonObject.get("content").getAsString();
71 return new AddContentOverlay(content);
72 }
73
74 public static List<AddContentOverlay> fromJsonArray(JsonArray jsonArray) {
75 if (jsonArray == null) {
76 return EMPTY_LIST;
77 }
78 ArrayList<AddContentOverlay> list = new ArrayList<AddContentOverlay>(jsonArray.size());
79 Iterator<JsonElement> iterator = jsonArray.iterator();
80 while (iterator.hasNext()) {
81 list.add(fromJson(iterator.next().getAsJsonObject()));
82 }
83 return list;
84 }
85
86 /**
87 * The new content of the file.
88 */
89 public String getContent() {
90 return content;
91 }
92
93 public String getType() {
94 return type;
95 }
96
97 @Override
98 public int hashCode() {
99 HashCodeBuilder builder = new HashCodeBuilder();
100 builder.append(type);
101 builder.append(content);
102 return builder.toHashCode();
103 }
104
105 public JsonObject toJson() {
106 JsonObject jsonObject = new JsonObject();
107 jsonObject.addProperty("type", type);
108 jsonObject.addProperty("content", content);
109 return jsonObject;
110 }
111
112 @Override
113 public String toString() {
114 StringBuilder builder = new StringBuilder();
115 builder.append("[");
116 builder.append("type=");
117 builder.append(type + ", ");
118 builder.append("content=");
119 builder.append(content);
120 builder.append("]");
121 return builder.toString();
122 }
123
124}
GLenum type
static AddContentOverlay fromJson(JsonObject jsonObject)
static List< AddContentOverlay > fromJsonArray(JsonArray jsonArray)
union flutter::testing::@2836::KeyboardChange::@76 content