input: Write a function to port a given Java code snippet to Python 3. The function should take a string representation of the Java code as input and return the corresponding Python code as output. If the input is empty or does not represent a valid Java code snippet, the function should return an empty 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("public class Bar { public String bar( String s ) { return s.toLowerCase(); } }")=="def bar(s):\n return s.lower()"
  assert port_java_to_python("public class Baz { public void baz() { System.out.println(\"Hello, World!\"); } }")=="def baz():\n print(\"Hello, World!\")"
  assert port_java_to_python("")==""
  assert port_java_to_python("invalid code snippet")==""
output: def port_java_to_python(java_code):
      if not java_code:
          return ""
      
      import re
      method_pattern = re.compile(r'public\s+(\w+)\s+(\w+)\s*\(([^)]*)\)\s*{([^}]*)}')
      match = method_pattern.search(java_code)
      
      if not match:
          return ""
      
      return_type, method_name, params, body = match.groups()
      params = [p.strip().split()[-1] for p in params.split(',')] if params else []
      body = body.strip()
      
      if return_type == "void":
          return f"def {method_name}({', '.join(params)}):\n {body.replace('System.out.println', 'print').replace(';', '')}"
      else:
          return f"def {method_name}({', '.join(params)}):\n return {body.replace('return ', '').replace(';', '').replace('.toLowerCase()', '.lower()')}"