summaryrefslogtreecommitdiff
path: root/generator/templates/function_template.java
blob: 96ac7cf99521196bbc831cfa2d0529366e1dda1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{% extends "struct_function_template.java" %}

    {%- block params %}
    {%- if params is defined %}
    {%- for p in params %}
    {%- if p.origin not in ('success', 'resultCode', 'info') or kind != "response" %}{% set see, deprecated, since, history, spacing, begin, end, prefix = p.see, p.deprecated, p.since, p.history, '    ', '/**', ' */', ' * ' %}
    {%- include "javadoc_version_info.java" %}
    {%- if p.deprecated is not none %}
    @Deprecated
    {%- endif %}
    public static final String {{p.key}} = "{{p.origin}}";
    {%- endif %}
    {%- endfor %}
    {%- endif %}
    {%- endblock %}

    {%- block constructor_simple %}
    public {{class_name}}() {
        super(FunctionID.{{function_id}}.toString());
    }{% endblock -%}

    {%- block setter %}
    {%- for p in params|rejectattr('name') %}
    {%- if p.origin not in ('success', 'resultCode', 'info') or kind != "response" %}

    /**
     * Sets the {{p.origin}}.
     *
     {%- include "javadoc_template.java" %}
     */
    {%- if p.deprecated is defined and p.deprecated is not none %}
    @Deprecated
    {%- endif %}
    public {{class_name}} set{{p.title}}({% if p.mandatory %}@NonNull {% endif %}{{p.return_type}} {{p.last}}) {
        setParameters({{p.key}}, {{p.last}});
        return this;
    }

    /**
     * Gets the {{p.origin}}.
     *
     {%- include "javadoc_return.java" %}
     */
    {%- if p.SuppressWarnings is defined %}
    @SuppressWarnings("{{p.SuppressWarnings}}")
    {%- endif %}
    {%- if p.deprecated is defined and p.deprecated is not none %}
    @Deprecated
    {%- endif %}
    public {{p.return_type}} get{{p.title}}() {
        {%- if p.return_type in ['String', 'Boolean', 'Integer'] %}
        return get{{p.return_type}}({{p.key}});
        {%- elif p.return_type in ['Float'] %}
        Object object = getParameters({{p.key}});
        return SdlDataTypeConverter.objectToFloat(object);
        {%- elif p.return_type in ['Double'] %}
        Object object = getParameters({{p.key}});
        return SdlDataTypeConverter.objectToDouble(object);
        {%- else %}
        {%- set clazz = p.return_type %}
        {%- if p.return_type.startswith('List')%}{%set clazz = p.return_type[5:-1]%}{% endif %}
        return ({{p.return_type}}) getObject({{clazz}}.class, {{p.key}});
        {%- endif %}
    }

    {%- endif %}
    {%- endfor %}
    {%- endblock %}