Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PostfixTemplateDescriptor.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 description of a postfix completion template.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final PostfixTemplateDescriptor[] EMPTY_ARRAY = new PostfixTemplateDescriptor[0];
35
36 public static final List<PostfixTemplateDescriptor> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The template name, shown in the UI.
40 */
41 private final String name;
42
43 /**
44 * The unique template key, not shown in the UI.
45 */
46 private final String key;
47
48 /**
49 * A short example of the transformation performed when the template is applied.
50 */
51 private final String example;
52
53 /**
54 * Constructor for {@link PostfixTemplateDescriptor}.
55 */
56 public PostfixTemplateDescriptor(String name, String key, String example) {
57 this.name = name;
58 this.key = key;
59 this.example = example;
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (obj instanceof PostfixTemplateDescriptor) {
66 return
67 ObjectUtilities.equals(other.name, name) &&
68 ObjectUtilities.equals(other.key, key) &&
69 ObjectUtilities.equals(other.example, example);
70 }
71 return false;
72 }
73
74 public static PostfixTemplateDescriptor fromJson(JsonObject jsonObject) {
75 String name = jsonObject.get("name").getAsString();
76 String key = jsonObject.get("key").getAsString();
77 String example = jsonObject.get("example").getAsString();
78 return new PostfixTemplateDescriptor(name, key, example);
79 }
80
81 public static List<PostfixTemplateDescriptor> fromJsonArray(JsonArray jsonArray) {
82 if (jsonArray == null) {
83 return EMPTY_LIST;
84 }
85 ArrayList<PostfixTemplateDescriptor> list = new ArrayList<PostfixTemplateDescriptor>(jsonArray.size());
86 Iterator<JsonElement> iterator = jsonArray.iterator();
87 while (iterator.hasNext()) {
88 list.add(fromJson(iterator.next().getAsJsonObject()));
89 }
90 return list;
91 }
92
93 /**
94 * A short example of the transformation performed when the template is applied.
95 */
96 public String getExample() {
97 return example;
98 }
99
100 /**
101 * The unique template key, not shown in the UI.
102 */
103 public String getKey() {
104 return key;
105 }
106
107 /**
108 * The template name, shown in the UI.
109 */
110 public String getName() {
111 return name;
112 }
113
114 @Override
115 public int hashCode() {
116 HashCodeBuilder builder = new HashCodeBuilder();
117 builder.append(name);
118 builder.append(key);
119 builder.append(example);
120 return builder.toHashCode();
121 }
122
123 public JsonObject toJson() {
124 JsonObject jsonObject = new JsonObject();
125 jsonObject.addProperty("name", name);
126 jsonObject.addProperty("key", key);
127 jsonObject.addProperty("example", example);
128 return jsonObject;
129 }
130
131 @Override
132 public String toString() {
133 StringBuilder builder = new StringBuilder();
134 builder.append("[");
135 builder.append("name=");
136 builder.append(name + ", ");
137 builder.append("key=");
138 builder.append(key + ", ");
139 builder.append("example=");
140 builder.append(example);
141 builder.append("]");
142 return builder.toString();
143 }
144
145}
static List< PostfixTemplateDescriptor > fromJsonArray(JsonArray jsonArray)
static PostfixTemplateDescriptor fromJson(JsonObject jsonObject)
const char * name
Definition fuchsia.cc:50