Files
snowy/codegen/lib/java.py
2026-08-12 07:09:10 -05:00

15 lines
568 B
Python

def java_float(value: float) -> str:
return f"{value}f"
def java_static_invoke(closure: str, option_name: str) -> str:
"""Turns a "com.example.MyMod::method" closure reference into a zero-arg
static method call expression, for APIs that need an already-computed
value (e.g. Block) rather than a functional-interface reference."""
if "::" not in closure:
raise ValueError(f"{option_name}: closure must be of the form 'pkg.Class::method', got: {closure!r}")
owner, _, method = closure.partition("::")
return f"{owner}.{method}()"