Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java

Issue 488413003: Initial factory constructors for generated objects in Java server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: review and rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java
index b960ec3f329be507b3ebd2c20718dce5199d8456..60d573ee0daaa51d24d4de4ce2c59426253be7a2 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/RefactoringProblem.java
@@ -19,10 +19,15 @@ package com.google.dart.server.generated.types;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import com.google.common.collect.Lists;
+import com.google.dart.server.utilities.general.JsonUtilities;
import com.google.dart.server.utilities.general.ObjectUtilities;
import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
+import java.util.ArrayList;
+import java.util.Iterator;
import org.apache.commons.lang3.StringUtils;
/**
@@ -33,11 +38,10 @@ import org.apache.commons.lang3.StringUtils;
@SuppressWarnings("unused")
public class RefactoringProblem {
- /**
- * An empty array of {@link RefactoringProblem}s.
- */
public static final RefactoringProblem[] EMPTY_ARRAY = new RefactoringProblem[0];
+ public static final List<RefactoringProblem> EMPTY_LIST = Lists.newArrayList();
+
/**
* The severity of the problem being represented.
*/
@@ -76,6 +80,25 @@ public class RefactoringProblem {
return false;
}
+ public static RefactoringProblem fromJson(JsonObject jsonObject) {
+ String severity = jsonObject.get("severity").getAsString();
+ String message = jsonObject.get("message").getAsString();
+ Location location = jsonObject.get("location") == null ? null : Location.fromJson(jsonObject.get("location").getAsJsonObject());
+ return new RefactoringProblem(severity, message, location);
+ }
+
+ public static List<RefactoringProblem> fromJsonArray(JsonArray jsonArray) {
+ if (jsonArray == null) {
+ return EMPTY_LIST;
+ }
+ ArrayList<RefactoringProblem> list = new ArrayList<RefactoringProblem>(jsonArray.size());
+ Iterator<JsonElement> iterator = jsonArray.iterator();
+ while (iterator.hasNext()) {
+ list.add(fromJson(iterator.next().getAsJsonObject()));
+ }
+ return list;
+ }
+
/**
* The location of the problem being represented. This field is omitted unless there is a specific
* location associated with the problem (such as a location where an element being renamed will be

Powered by Google App Engine
This is Rietveld 408576698