private GenerateContentRequest buildGenerateContentRequest(List<Content> contents) {
    checkArgument(contents != null && !contents.isEmpty(), "contents can't be null or empty.");
    GenerateContentRequest.Builder requestBuilder =
        GenerateContentRequest.newBuilder()
            .setModel(resourceName)
            .addAllContents(contents)
            .setGenerationConfig(generationConfig)
            .addAllSafetySettings(safetySettings)
            .addAllTools(tools);

    if (toolConfig.isPresent()) {
      requestBuilder.setToolConfig(toolConfig.get());
    }

    if (systemInstruction.isPresent()) {
      requestBuilder.setSystemInstruction(systemInstruction.get());
    }

    return requestBuilder.build();
  }
Builds a {@link com.google.cloud.vertexai.api.GenerateContentRequest} based on a list of
contents and model configurations.
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/GenerativeModel.java