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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/AnalysisOptions.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/AnalysisOptions.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/AnalysisOptions.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/AnalysisOptions.java
index cce0fbd892ff9e0ca6a8d86212504346ea865005..c692c4db9f76b90a8b63fd34a7669eebfd7f97fa 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/AnalysisOptions.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/AnalysisOptions.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;
/**
@@ -34,11 +39,10 @@ import org.apache.commons.lang3.StringUtils;
@SuppressWarnings("unused")
public class AnalysisOptions {
- /**
- * An empty array of {@link AnalysisOptions}s.
- */
public static final AnalysisOptions[] EMPTY_ARRAY = new AnalysisOptions[0];
+ public static final List<AnalysisOptions> EMPTY_LIST = Lists.newArrayList();
+
/**
* True if the client wants to enable support for the proposed async feature.
*/
@@ -90,6 +94,27 @@ public class AnalysisOptions {
return false;
}
+ public static AnalysisOptions fromJson(JsonObject jsonObject) {
+ Boolean enableAsync = jsonObject.get("enableAsync") == null ? null : jsonObject.get("enableAsync").getAsBoolean();
+ Boolean enableDeferredLoading = jsonObject.get("enableDeferredLoading") == null ? null : jsonObject.get("enableDeferredLoading").getAsBoolean();
+ Boolean enableEnums = jsonObject.get("enableEnums") == null ? null : jsonObject.get("enableEnums").getAsBoolean();
+ Boolean generateDart2jsHints = jsonObject.get("generateDart2jsHints") == null ? null : jsonObject.get("generateDart2jsHints").getAsBoolean();
+ Boolean generateHints = jsonObject.get("generateHints") == null ? null : jsonObject.get("generateHints").getAsBoolean();
+ return new AnalysisOptions(enableAsync, enableDeferredLoading, enableEnums, generateDart2jsHints, generateHints);
+ }
+
+ public static List<AnalysisOptions> fromJsonArray(JsonArray jsonArray) {
+ if (jsonArray == null) {
+ return EMPTY_LIST;
+ }
+ ArrayList<AnalysisOptions> list = new ArrayList<AnalysisOptions>(jsonArray.size());
+ Iterator<JsonElement> iterator = jsonArray.iterator();
+ while (iterator.hasNext()) {
+ list.add(fromJson(iterator.next().getAsJsonObject()));
+ }
+ return list;
+ }
+
/**
* True if the client wants to enable support for the proposed async feature.
*/

Powered by Google App Engine
This is Rietveld 408576698