Add a method allowed by the resource

@param method
484370
public void addAllowedMethod(String method) {

		Constraint.ensureNotEmpty(method, String.format("Invalid method '%s'", method));
		Constraint.ensureTrue(HttpMethod.isValidMethod(method), String.format("Invalid method '%s'", method));
		allowedMethods.add(method.toUpperCase());
	}
809639
public void setArguments(Method method) {

		Parameter[] parameters = method.getParameters();
		Class<?>[] parameterTypes = method.getParameterTypes();
		Annotation[][] annotations = method.getParameterAnnotations();

		async = isAsync(method.getReturnType());
		returnType = method.getReturnType();

		int index = 0;
		Map<String, MethodParameter> arguments = new HashMap<>();

		for (Annotation[] ann : annotations) {

			String name = null;
			ParameterType type = null;
			String defaultValue = null;
			boolean raw = false;
			Class<? extends ValueReader> valueReader = null;
			Class<? extends ContextProvider> contextValueProvider = null;

			for (Annotation annotation : ann) {

				if (annotation instanceof PathParam) {
					// find path param ... and set index ...
					name = ((PathParam) annotation).value();
					type = ParameterType.path;
				}

				if (annotation instanceof QueryParam) {
					// add param
					name = ((QueryParam) annotation).value();
					type = ParameterType.query;
				}

				if (annotation instanceof Raw) {
					raw = true;
				}

				if (annotation instanceof FormParam) {
					type = ParameterType.form;
					name = ((FormParam) annotation).value();
				}

				if (annotation instanceof CookieParam) {
					type = ParameterType.cookie;
					name = ((CookieParam) annotation).value();
				}

				if (annotation instanceof HeaderParam) {
					type = ParameterType.header;
					name = ((HeaderParam) annotation).value();
				}

				if (annotation instanceof MatrixParam) {
					type = ParameterType.matrix;
					name = ((MatrixParam) annotation).value();
				}

				if (annotation instanceof DefaultValue) {
					defaultValue = ((DefaultValue) annotation).value();
				}

				if (annotation instanceof RequestReader) {
					valueReader = ((RequestReader) annotation).value();
				}

				if (annotation instanceof ContextReader) {
					contextValueProvider = ((ContextReader) annotation).value();
				}

				if (annotation instanceof Context) {
					type = ParameterType.context;
					name = parameters[index].getName();
				}
			}

			// if no name provided than parameter is considered unknown (it might be request body, but we don't know)
			if (name == null) {

				// try to find out what parameter type it is ... POST, PUT have a body ...
				// regEx path might not have a name ...
				MethodParameter param = findParameter(index);
				if (param != null) {

					Assert.isNull(param.getDataType(), "Duplicate argument type given: " + parameters[index].getName());
					param.argument(parameterTypes[index], index); // set missing argument type and index
				} else {

					if (valueReader == null) {
						valueReader = reader; // take reader from method / class definition
					} else {
						reader = valueReader; // set body reader from field
					}

					name = parameters[index].getName();
					type = ParameterType.unknown;
				}
			}

			// collect only needed params for this method
			if (name != null) {

				// set context provider from method annotation if fitting
				if (contextValueProvider == null && contextProvider != null) {
					Type generic = ClassFactory.getGenericType(contextProvider);
				    if (ClassFactory.checkIfCompatibleTypes(parameterTypes[index], generic)) {
					    contextValueProvider = contextProvider;
				    }
				}

				MethodParameter parameter = provideArgument(name, type, defaultValue, raw, parameterTypes[index], valueReader, contextValueProvider, index);
				arguments.put(name, parameter);
			}

			index++;
		}

		setUsedArguments(arguments);
	}
610950
public void addEngine(ReqMethod method, LinkedEngine engine) {
        for (ReqMethod md : method.parse()) {
            LinkedEngine[] methodEngines = engines[md.ordinal()];
            if (methodEngines.length == 0) {
                methodEngines = new LinkedEngine[] { engine };
            } else {
                methodEngines = Arrays.copyOf(methodEngines, methodEngines.length + 1);
                methodEngines[methodEngines.length - 1] = engine;
            }
            engines[md.ordinal()] = methodEngines;
            engineCount++;
        }
        clearCache();
    }
878987
private void processMethod(final Method method) {
    CommandArgument annotation = method.getAnnotation(CommandArgument.class);
    if (annotation != null) {
      final String name = method.getName();
      final Class<?>[] paramTypes = method.getParameterTypes();
      final Annotation[][] paramAnnotations = method.getParameterAnnotations();
      final ArgumentProcessor<Object[]> argProcessor = new ArgumentProcessor<Object[]>();
      final Object[] defaultParams = new Object[paramTypes.length];
      final List<Integer> positionalParams = new ArrayList<Integer>();

      String key = annotation.value();
      if (key.equals("")) {
        key = name;
      }

      for (int i = 0; i < paramAnnotations.length; i++) {
        Class<?> paramType = paramTypes[i];
        if (paramType == Integer.class || paramType == int.class) {
          defaultParams[i] = 0;
        } else if (paramType == Long.class || paramType == long.class) {
            defaultParams[i] = 0L;
        } else if (paramType == Double.class || paramType == double.class) {
          defaultParams[i] = 0.0;
        } else if (paramType == Float.class || paramType == float.class) {
          defaultParams[i] = (float) 0.0;
        } else if (paramType == String.class) {
          defaultParams[i] = "";
        } else if (paramType == File.class) {
          defaultParams[i] = null;
        } else if (paramType == Boolean.class || paramType == boolean.class) {
          defaultParams[i] = false;
        } else {
          throw new IllegalArgumentException("Invalid type (" + paramType.getCanonicalName() + ") for option parameter: method=" + method.getDeclaringClass().getCanonicalName() + "." + name);
        }

        int j;
        for (j = 0; j < paramAnnotations[i].length; j++) {
          if (paramAnnotations[i][j] instanceof OptionArgument) {
            OptionArgument optAnnotation = (OptionArgument) paramAnnotations[i][j];
            String optKey = optAnnotation.value();
            if (optKey.equals("")) {
              throw new IllegalArgumentException("OptionArgument on parameter requires key (method=`" + method.getDeclaringClass().getCanonicalName() + "." + name + "').");
            }

            char optShortKey = optAnnotation.shortKey();
            if (optShortKey == '\0') {
              optShortKey = optKey.charAt(0);
            }

            final int index = i;
            if (paramType == Integer.class || paramType == int.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Integer.parseInt(argq.remove());
                }
              });
            } else if (paramType == Long.class || paramType == long.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Long.parseLong(argq.remove());
                }
              });
            } else if (paramType == Boolean.class || paramType == boolean.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = true;
                }
              });
            } else if (paramType == String.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = argq.remove();
                }
              });
            } else if (paramType == Double.class || paramType == double.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Double.parseDouble(argq.remove());
                }
              });
            } else if (paramType == Float.class || paramType == float.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Float.parseFloat(argq.remove());
                }
              });
            } else if (paramType == File.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = new File(argq.remove());
                }
              });
            }

            break;
          }
        }

        // If there is no OptionArgument annotation, treat it as a
        // positional parameter.
        if (j >= paramAnnotations[i].length) {
          positionalParams.add(i);
        }
      }

      // The default command will parse out all the positional parameters
      // from what's left over after all the options have been processed.
      argProcessor.setDefaultCommand(new Command<Object[]>() {
        public void process(Queue<String> argq, Object[] state) {
          for (int index : positionalParams) {
            if (argq.isEmpty()) {
              break;
            }
            Class<?> paramType = paramTypes[index];
            if (paramType == Integer.class || paramType == int.class) {
              state[index] = Integer.parseInt(argq.remove());
            } else if (paramType == Long.class || paramType == long.class) {
              state[index] = Long.parseLong(argq.remove());
            } else if (paramType == Double.class || paramType == double.class) {
              state[index] = Double.parseDouble(argq.remove());
            } else if (paramType == Float.class || paramType == float.class) {
              state[index] = Float.parseFloat(argq.remove());
            } else if (paramType == String.class) {
              state[index] = argq.remove();
            } else if (paramType == File.class) {
              state[index] = new File(argq.remove());
            } else if (paramType == Boolean.class || paramType == boolean.class) {
              state[index] = Boolean.parseBoolean(argq.remove());
            } else {
              throw new UnexpectedException();
            }
          }
        }
      });

      // Add the command that processes its arguments and invokes the
      // method.
      addCommand(key, new Command<T>(){
        public void process(Queue<String> argq, T state) {
          Object[] params = defaultParams.clone();
          argProcessor.process(argq, params);
          try {
            method.invoke(state, params);
          } catch (IllegalArgumentException e) {
            throw new UnexpectedException(e);
          } catch (IllegalAccessException e) {
            throw new UnexpectedException(e);
          } catch (InvocationTargetException e) {
            throw new UnexpectedException(e);
          }
        }
      });
    }
  }
1118179
private void add(HttpMethod method, String url, String acceptedType, Object target) {
        RouteEntry entry = new RouteEntry();
        entry.httpMethod = method;
        entry.path = url;
        entry.target = target;
        entry.acceptedType = acceptedType;
        LOG.debug("Adds route: " + entry);
        // Adds to end of list
        routes.add(entry);
    }
1058778
public void addMethodLine(String className, String methodName, String methodSignature, SourceLineRange range) {
        methodLineMap.put(new MethodDescriptor(className, methodName, methodSignature), range);
    }
278325
function addMethod(name, method) {
        if (method !== undefined) {
            methods[name] = method;
        }
        return methods[name];
    }
1077757
protected final void generateSourcePublicMethodDeclaration(SourceWriter sourceWriter, JMethod method) {

    StringBuilder arguments = new StringBuilder();
    for (JParameter parameter : method.getParameters()) {
      if (arguments.length() > 0) {
        arguments.append(", ");
      }
      arguments.append(parameter.getType().getQualifiedSourceName());
      arguments.append(" ");
      arguments.append(parameter.getName());
    }
    generateSourcePublicMethodDeclaration(sourceWriter, method.getReturnType().getQualifiedSourceName(),
        method.getName(), arguments.toString(), false);
  }
244383
@Override
    public void setMethod(MethodValues method) {
        this.myMethod = method;
        super.setFirstLineChanged();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "setMethod(v): " + (null != method ? method.getName() : null));
        }
    }
325446
def method(self, method):
        
        if method is None:
            raise ValueError("Invalid value for `method`, must not be `None`")  # noqa: E501
        allowed_values = ["WEBHOOK", "EMAIL", "PAGERDUTY"]  # noqa: E501
        if method not in allowed_values:
            raise ValueError(
                "Invalid value for `method` ({0}), must be one of {1}"  # noqa: E501
                .format(method, allowed_values)
            )

        self._method = method
1348941
public RequestHeader withMethod(Method method) {
        return new RequestHeader(method, uri, protocol, acceptedResponseProtocols, principal, headers, lowercaseHeaders);
    }
121222
@UnstableApi
    public final void setPrivateKeyMethod(OpenSslPrivateKeyMethod method) {
        ObjectUtil.checkNotNull(method, "method");
        Lock writerLock = ctxLock.writeLock();
        writerLock.lock();
        try {
            SSLContext.setPrivateKeyMethod(ctx, new PrivateKeyMethod(engineMap, method));
        } finally {
            writerLock.unlock();
        }
    }
1283404
@Override
    public void setMethod(String method) throws UnsupportedMethodException {
        MethodValues val = MethodValues.match(method, 0, method.length());
        if (null == val) {
            throw new UnsupportedMethodException("Illegal method " + method);
        }
        setMethod(val);
    }
1360220
private void storeMethod(Method method, Map<Key, Array> methodsMap) {
	Key methodName = KeyImpl.init(method.getName());

	Array methodArgs;
	synchronized (methodsMap) {
	    methodArgs = methodsMap.get(methodName);
	    if (methodArgs == null) {
		methodArgs = new ArrayImpl();
		methodsMap.put(methodName, methodArgs);
	    }
	}

	storeArgs(method, methodArgs);
	// Modifier.isStatic(method.getModifiers());
    }
808687
private void addWrapper(MethodSpec.Builder method, String pattern) {
    method.addComment("$S", pattern);
    for (Node node : WRAPPER_PARSER.parseWrapper(pattern)) {
      if (node instanceof Text) {
        method.addStatement("b.append($S)", ((Text)node).text());

      } else if (node instanceof Field) {
        Field field = (Field)node;
        switch (field.ch()) {
          case '0':
            method.beginControlFlow("if (timeType != null)");
            method.addStatement("formatTime(timeType, d, b)");
            method.nextControlFlow("else");
            method.addStatement("formatSkeleton(timeSkel, d, b)");
            method.endControlFlow();
            break;

          case '1':
            method.beginControlFlow("if (dateType != null)");
            method.addStatement("formatDate(dateType, d, b)");
            method.nextControlFlow("else");
            method.addStatement("formatSkeleton(dateSkel, d, b)");
            method.endControlFlow();
            break;
        }
      }
    }
  }
388096
def _addMethod(self, effect, verb, resource, conditions):
        """"""
        if verb != "*" and not hasattr(HttpVerb, verb):
            raise NameError("Invalid HTTP verb " + verb + ". Allowed verbs in HttpVerb class")
        resourcePattern = re.compile(self.pathRegex)
        if not resourcePattern.match(resource):
            raise NameError("Invalid resource path: " + resource + ". Path should match " + self.pathRegex)

        if resource[:1] == "/":
            resource = resource[1:]

        resourceArn = ("arn:aws:execute-api:" +
            self.region + ":" +
            self.awsAccountId + ":" +
            self.restApiId + "/" +
            self.stage + "/" +
            verb + "/" +
            resource)

        if effect.lower() == "allow":
            self.allowMethods.append({
                'resourceArn' : resourceArn,
                'conditions' : conditions
            })
        elif effect.lower() == "deny":
            self.denyMethods.append({
                'resourceArn' : resourceArn,
                'conditions' : conditions
            })
762171
protected void addReturnType(MethodDoc method, Content htmltree) {
        Type type = method.returnType();
        if (type != null) {
            Content linkContent = writer.getLink(
                    new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
            htmltree.addContent(linkContent);
            htmltree.addContent(writer.getSpace());
        }
    }