public static FunctionDeclaration fromFunc(
      String functionDescription, Method function, String... orderedParameterNames) {
    if (!Modifier.isStatic(function.getModifiers())) {
      throw new IllegalArgumentException(
          "Instance methods are not supported. Please use static methods.");
    }
    Schema.Builder parametersBuilder = Schema.newBuilder().setType(Type.OBJECT);

    Parameter[] parameters = function.getParameters();
    // If parameter names are provided, the number of parameter names should match the number of
    // parameters in the method.
    if (orderedParameterNames.length > 0 && orderedParameterNames.length != parameters.length) {
      throw new IllegalArgumentException(
          "The number of parameter names does not match the number of parameters in the method.");
    }

    for (int i = 0; i < parameters.length; i++) {
      if (orderedParameterNames.length == 0) {
        // If parameter names are not provided, try to retrieve them from reflection.
        if (!parameters[i].isNamePresent()) {
          throw new IllegalStateException(
              "Failed to retrieve the parameter name from reflection. Please compile your"
                  + " code with  \"-parameters\" flag or use `fromFunc(String, Method,"
                  + " String...)` to manually enter parameter names");
        }
        addParameterToParametersBuilder(
            parametersBuilder, parameters[i].getName(), parameters[i].getType());
      } else {
        addParameterToParametersBuilder(
            parametersBuilder, orderedParameterNames[i], parameters[i].getType());
      }
    }

    return FunctionDeclaration.newBuilder()
        .setName(function.getName())
        .setDescription(functionDescription)
        .setParameters(parametersBuilder)
        .build();
  }
Creates a FunctionDeclaration from a Java static method

<p><b>Note:</b>: If you don't want to manually provide parameter names, you can ignore
`orderedParameterNames` and compile your code with the "-parameters" flag. In this case, the
parameter names can be auto retrieved from reflection.

@param functionDescription A description of the method.
@param function A Java static method.
@param orderedParameterNames A list of parameter names in the order they are passed to the
    method.
@return a {@link com.google.cloud.vertexai.api.FunctionDeclaration} instance.
@throws IllegalArgumentException if the method is not a static method or the number of provided
    parameter names doesn't match the number of parameters in the callable function or
    parameter types in this method are not String, boolean, int, double, or float.
@throws IllegalStateException if the parameter names are not provided and cannot be retrieved
    from reflection
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/FunctionDeclarationMaker.java