// Copyright 2017 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 io.flutter.plugin.common;

/**
 * Command object representing a method call on a {@link FlutterMethodChannel}.
 */
public final class MethodCall {
    /**
     * The name of the called method.
     */
    public final String method;

    /**
     * Arguments for the call.
     */
    public final Object arguments;

    /**
     * Creates a {@link MethodCall} with the specified method name and arguments.
     *
     * @param method the method name String, not null.
     * @param arguments the arguments, a value supported by the channel's message codec.
     */
    public MethodCall(String method, Object arguments) {
        assert method != null;
        this.method = method;
        this.arguments = arguments;
    }
}

@@ -194,16 +194,67 @@
 ommon;%0A%0A
+import java.util.Map;%0Aimport org.json.JSONObject;%0A%0A
 /**%0A * C
@@ -487,24 +487,251 @@
 r the call.%0A
+     *%0A     * Consider using %7B@link #arguments()%7D for cases where a particular run-time type is expected.%0A     * Consider using %7B@link #argument(String)%7D when that run-time type is a %7B@link Map%7D%0A     * or a %7B@link JSONObject%7D.%0A
      */%0A    
@@ -1129,16 +1129,16 @@
 method;%0A
-
         
@@ -1170,11 +1170,1343 @@
 s;%0A    %7D
+%0A%0A    /**%0A     * Returns the arguments of this method call with a static type determined by the call-site.%0A     *%0A     * @param %3CT%3E the intended type of the arguments.%0A     * @return the arguments with static type T%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E T arguments() %7B%0A        return (T) arguments;%0A    %7D%0A%0A    /**%0A     * Returns a String-keyed argument of this method call, assuming %7B@link #arguments%7D is a%0A     * %7B@link Map%7D or a %7B@link JSONObject%7D. The static type of the returned result is determined%0A     * by the call-site.%0A     *%0A     * @param %3CT%3E the intended type of the argument.%0A     * @param key the String key.%0A     * @return the argument value at the specified key, with static type T, or %7B@code null%7D, if%0A     * such an entry is not present.%0A     * @throws ClassCastException if %7B@link #arguments%7D can be cast to neither %7B@link Map%7D nor%0A     * %7B@link JSONObject%7D.%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E T argument(String key) %7B%0A        if (arguments == null) %7B%0A            return null;%0A        %7D else if (arguments instanceof Map) %7B%0A            return (T) ((Map%3C?, ?%3E) arguments).get(key);%0A        %7D else if (arguments instanceof JSONObject) %7B%0A            return (T) ((JSONObject) arguments).opt(key);%0A        %7D else %7B%0A            throw new ClassCastException();%0A        %7D%0A    %7D
 %0A%7D%0A

Add convenience accessors to get arguments from MethodCall w/o unchecked warnings (#3559)