org.chromium.sdk/src/org/chromium/sdk/internal/protocol/CommandResponse.java
changeset 2 e4420d2515f1
child 355 8726e95bcbba
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.chromium.sdk/src/org/chromium/sdk/internal/protocol/CommandResponse.java	Wed Dec 23 17:13:18 2009 -0800
@@ -0,0 +1,49 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.sdk.internal.protocol;
+
+import java.util.EnumSet;
+
+import org.chromium.sdk.internal.protocolparser.EnumValueCondition;
+import org.chromium.sdk.internal.protocolparser.JsonField;
+import org.chromium.sdk.internal.protocolparser.JsonOverrideField;
+import org.chromium.sdk.internal.protocolparser.JsonSubtype;
+import org.chromium.sdk.internal.protocolparser.JsonSubtypeCasting;
+import org.chromium.sdk.internal.protocolparser.JsonSubtypeConditionCustom;
+import org.chromium.sdk.internal.protocolparser.JsonType;
+
+/**
+ * A generic type for all command responses. There are 2 subtypes; one for
+ * success responses and one for failure responses.
+ */
+@JsonType
+public interface CommandResponse extends JsonSubtype<IncomingMessage> {
+
+  @JsonOverrideField
+  @JsonSubtypeConditionCustom(condition=TypeValueCondition.class)
+  MessageType getType();
+
+  class TypeValueCondition extends EnumValueCondition<MessageType> {
+    public TypeValueCondition() {
+      super(EnumSet.of(MessageType.response));
+    }
+  }
+
+  /**
+   * Id of the corresponding request sent to debugger.
+   */
+  @JsonField(jsonLiteralName="request_seq")
+  long getRequestSeq();
+
+  String getCommand();
+
+  boolean success();
+
+  @JsonSubtypeCasting
+  SuccessCommandResponse asSuccess();
+
+  @JsonSubtypeCasting
+  FailedCommandResponse asFailure();
+}