input: Write a function to port a given Java code snippet to Python 3. If the given code snippet is empty then return None. The function should accept a string containing Java code and return the equivalent Python code as a string.
  assert port_java_to_python("public class Foo { public int foo( int a, int b ) { return a + b; } }") == "def foo(a, b):\n return a + b"
  assert port_java_to_python("") == None
output: def port_java_to_python(java_code):
      if not java_code:
          return None
      java_code = java_code.strip()
      if java_code.startswith("public class"):
          method_start = java_code.find("public")
          method_code = java_code[method_start:]
          method_name_start = method_code.find(" ") + 1
          method_name_end = method_code.find("(")
          method_name = method_code[method_name_start:method_name_end]
          params_start = method_code.find("(") + 1
          params_end = method_code.find(")")
          params = method_code[params_start:params_end].split(", ")
          params = [param.split(" ")[-1] for param in params]
          body_start = method_code.find("{") + 1
          body_end = method_code.rfind("}")
          body = method_code[body_start:body_end].strip()
          body = body.replace("return", "return ")
          return f"def {method_name}({', '.join(params)}):\n {body}"