code: def generate_schema(class_name, schema):
      """
      Generate schema Java class.
  
      :param class_name: name of the class
      :param schema: information about the class
      """
      superclass = schema["superclass"]
      if superclass == "Schema":
          superclass = "Object"
  
      has_map = False
      is_model_builder = False
      has_inherited = False
      for field in schema["fields"]:
          if field["name"] == "__meta":
              continue
          if field["is_inherited"]:
              has_inherited = True
              continue
          if field["type"].startswith("Map"):
              has_map = True
          if field["name"] == "can_build":
              is_model_builder = True
  
      fields = []
      for field in schema["fields"]:
          if field["name"] == "__meta":
              continue
          java_type = translate_type(
              field["type"], field["schema_name"]
          )
          java_value = get_java_value(field)
  
          # hackery: we flatten the parameters up into the ModelBuilder schema, rather than nesting them in the
          # parameters schema class...
          if (
              False
              and is_model_builder
              and field["name"] == "parameters"
          ):
              fields.append(
                  (
                      "parameters",
                      "null",
                      "ModelParameterSchemaV3[]",
                      field["help"],
                      field["is_inherited"],
                  )
              )
          else:
              fields.append(
                  (
                      field["name"],
                      java_value,
                      java_type,
                      field["help"],
                      field["is_inherited"],
                  )
              )
  
      class_decl = class_name
      if "generics" in schema:
          class_decl += (
              "<"
              + ", ".join(
                  "%s extends %s" % (t, long_type)
                  for t, long_type in schema["generics"]
              )
              + ">"
          )
      super_decl = superclass
      if "super_generics" in schema:
          super_decl += "<" + ", ".join(schema["super_generics"]) + ">"
  
      yield "/*"
      yield " * This file is auto-generated by h2o-3/h2o-bindings/bin/gen_java.py"
      yield " * Copyright 2016 H2O.ai;  Apache License Version 2.0 (see LICENSE for details)"
      yield " */"
      yield "package water.bindings.pojos;"
      yield ""
      yield "import com.google.gson.Gson;"
      yield "import com.google.gson.annotations.*;"
      yield "import java.util.Map;" if has_map else None
      yield ""
      yield ""
      yield "public class %s extends %s {" % (
          class_decl,
          super_decl,
      ) if super_decl != "Object" else None
      yield "public class %s {" % (
          class_decl
      ) if super_decl == "Object" else None
      yield ""
      for name, value, ftype, fhelp, inherited in fields:
          if inherited:
              continue
          ccname = translate_name(name)
          yield "    /**"
          yield bi.wrap(fhelp, indent="     * ")
          yield "     */"
          yield '    @SerializedName("%s")' % name if name != ccname else None
          yield "    public %s %s;" % (ftype, ccname)
          yield ""
      if has_inherited:
          yield ""
          yield "    /*" + ("-" * 114)
          yield "    //" + (" " * 50) + "INHERITED"
          yield "    //" + ("-" * 114)
          yield ""
          for name, value, ftype, fhelp, inherited in fields:
              if not inherited:
                  continue
              yield bi.wrap(fhelp, "    // ")
              yield "    public %s %s;" % (ftype, translate_name(name))
              yield ""
          yield "    */"
          yield ""
      yield "    /**"
      yield "     * Public constructor"
      yield "     */"
      yield "    public %s() {" % class_name
      for name, value, _, _, _ in fields:
          if name == "parameters":
              continue
          if value == "null":
              continue
          yield "        %s = %s;" % (translate_name(name), value)
      yield "    }"
      yield ""
      yield "    /**"
      yield "     * Return the contents of this object as a JSON String."
      yield "     */"
      yield "    @Override"
      yield "    public String toString() {"
      yield "        return new Gson().toJson(this);"
      yield "    }"
      yield ""
      yield "}"
  
file_path: h2o-3/h2o-bindings/bin/gen_java.py
imports: import re
  import textwrap
  import bindings
label_desc: Use image node_id 5 for calling a global function with example usage: generate_schema(class_name, schema) without return types