input: Write a function to port a given Java code snippet to Python 3. The function should take the Java code as a string input and return the corresponding Python code as a string output.
  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'
output: def port_java_to_python(java_code):
      import re
      method_pattern = re.compile(r'public\s+(\w+)\s+(\w+)\s*\(\s*(\w+)\s+(\w+)\s*,\s*(\w+)\s+(\w+)\s*\)\s*\{\s*return\s+(\w+)\s*\+\s*(\w+)\s*;\s*\}')
      match = method_pattern.search(java_code)
      if match:
          return_type, method_name, param1_type, param1_name, param2_type, param2_name, var1, var2 = match.groups()
          return f"def {method_name}({param1_name}, {param2_name}):\n return {param1_name} + {param2_name}"