summaryrefslogtreecommitdiff
path: root/generator/templates/struct_template.java
blob: 4e5a2b4f47918d7db4529e660970d37f0250c9e7 (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
{%extends"struct_function_template.java"%}

        {%-block params%}
        {%-if params is defined%}
        {%-for p in params%}{%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}}";
        {%-endfor%}
        {%-endif%}
        {%-endblock%}

        {%-block constructor_simple%}
public {{class_name}}(){}
        {%-endblock-%}

        {%-block setter%}
        {%-for p in params|rejectattr('name')%}

        /**
         * 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}}){
        setValue({{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=getValue({{p.key}});
        return SdlDataTypeConverter.objectToFloat(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%}
        }

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