Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
BulkFix.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 bulk fixes to a library.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class BulkFix {
33
34 public static final BulkFix[] EMPTY_ARRAY = new BulkFix[0];
35
36 public static final List<BulkFix> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The path of the library.
40 */
41 private final String path;
42
43 /**
44 * A list of bulk fix details.
45 */
46 private final List<BulkFixDetail> fixes;
47
48 /**
49 * Constructor for {@link BulkFix}.
50 */
51 public BulkFix(String path, List<BulkFixDetail> fixes) {
52 this.path = path;
53 this.fixes = fixes;
54 }
55
56 @Override
57 public boolean equals(Object obj) {
58 if (obj instanceof BulkFix) {
59 BulkFix other = (BulkFix) obj;
60 return
61 ObjectUtilities.equals(other.path, path) &&
62 ObjectUtilities.equals(other.fixes, fixes);
63 }
64 return false;
65 }
66
67 public static BulkFix fromJson(JsonObject jsonObject) {
68 String path = jsonObject.get("path").getAsString();
69 List<BulkFixDetail> fixes = BulkFixDetail.fromJsonArray(jsonObject.get("fixes").getAsJsonArray());
70 return new BulkFix(path, fixes);
71 }
72
73 public static List<BulkFix> fromJsonArray(JsonArray jsonArray) {
74 if (jsonArray == null) {
75 return EMPTY_LIST;
76 }
77 ArrayList<BulkFix> list = new ArrayList<BulkFix>(jsonArray.size());
78 Iterator<JsonElement> iterator = jsonArray.iterator();
79 while (iterator.hasNext()) {
80 list.add(fromJson(iterator.next().getAsJsonObject()));
81 }
82 return list;
83 }
84
85 /**
86 * A list of bulk fix details.
87 */
89 return fixes;
90 }
91
92 /**
93 * The path of the library.
94 */
95 public String getPath() {
96 return path;
97 }
98
99 @Override
100 public int hashCode() {
101 HashCodeBuilder builder = new HashCodeBuilder();
102 builder.append(path);
103 builder.append(fixes);
104 return builder.toHashCode();
105 }
106
107 public JsonObject toJson() {
108 JsonObject jsonObject = new JsonObject();
109 jsonObject.addProperty("path", path);
110 JsonArray jsonArrayFixes = new JsonArray();
111 for (BulkFixDetail elt : fixes) {
112 jsonArrayFixes.add(elt.toJson());
113 }
114 jsonObject.add("fixes", jsonArrayFixes);
115 return jsonObject;
116 }
117
118 @Override
119 public String toString() {
120 StringBuilder builder = new StringBuilder();
121 builder.append("[");
122 builder.append("path=");
123 builder.append(path + ", ");
124 builder.append("fixes=");
125 builder.append(StringUtils.join(fixes, ", "));
126 builder.append("]");
127 return builder.toString();
128 }
129
130}
static List< BulkFixDetail > fromJsonArray(JsonArray jsonArray)
static List< BulkFix > fromJsonArray(JsonArray jsonArray)
Definition BulkFix.java:73
static BulkFix fromJson(JsonObject jsonObject)
Definition BulkFix.java:67
BulkFix(String path, List< BulkFixDetail > fixes)
Definition BulkFix.java:51