input: Write a function to port a Java code snippet to Python 3. The function should take in a string representation of the Java code snippet and return the equivalent Python 3 code snippet. If the input string is empty or the Java code snippet is invalid, 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 int bar( int x, int y ) { return x * y; } }")=="def bar(x, y):\n return x * y"
  assert port_java_to_python("")==""
  assert port_java_to_python("public class Invalid { public int invalid( int a ) { return a + b; } }")==""
  assert port_java_to_python("public class Baz { public int baz( int p, int q ) { int r = p - q; return r; } }")=="def baz(p, q):\n r = p - q\n return r"
output: def port_java_to_python(java_code):
      if not java_code:
          return ""
      if "public class" not in java_code or "public int" not in java_code:
          return ""
      
      class_name = java_code.split("public class")[1].split("{")[0].strip()
      method_name = java_code.split("public int")[1].split("(")[0].strip()
      params = java_code.split("(")[1].split(")")[0].split(",")
      params = [p.strip() for p in params]
      body = java_code.split("{")[2].split("}")[0].strip()
      
      if "return" not in body:
          return ""
      
      return_statement = body.split("return")[1].strip()
      
      python_code = f"def {method_name}({', '.join(params)}):\n {body.replace('return', 'return ')}"
      return python_code