alef 0.78.0

Opinionated polyglot binding generator for Rust libraries
Documentation
import {{ package_name }}.*;
{% if needs_mapper %}import com.fasterxml.jackson.databind.ObjectMapper;
{% endif %}

public final class Example {
    public static void main(String[] args) throws Exception {
{% if needs_mapper %}        var MAPPER = new ObjectMapper();
{% endif %}
{% if expects_error and not client_factory %}        try {
{% endif %}
{% for line in setup_lines %}        {{ line }}
{% endfor %}
{% if client_factory %}        var apiKey = System.getenv("{{ api_key_var }}");
        if (apiKey == null || apiKey.isEmpty()) throw new IllegalStateException("{{ api_key_var }} must be set");
        try (var client = {{ class_name }}.{{ client_factory }}({{ client_args }})) {
{% if returns_void %}        client.{{ function_name }}({{ args }});
{% else %}        var {{ result_var }} = client.{{ function_name }}({{ args }});
{% endif %}
{% elif returns_void %}        {{ class_name }}.{{ function_name }}({{ args }});
{% else %}        var {{ result_var }} = {{ class_name }}.{{ function_name }}({{ args }});
{% endif %}
{% if not returns_void %}{% if presentation %}{% for operation in presentation %}{% if operation.kind == "show" %}        System.out.println({{ operation.expression }});
{% elif operation.kind == "iterate" %}        for (var {{ operation.item }} : {{ operation.expression }}) {
{% for field in operation.fields %}            System.out.println({{ field }});
{% endfor %}        }
{% endif %}{% endfor %}{% else %}        System.out.println({{ result_var }});
{% endif %}{% endif %}
{% if client_factory %}        }
{% endif %}
{% if expects_error %}{% if client_factory %}        catch ({{ exception_class }} error) {
{% else %}        } catch ({{ exception_class }} error) {
{% endif %}
            System.err.println(error.getClass().getSimpleName() + ": " + error.getMessage());
        }
{% endif %}
    }
}