Skip to content

Commit 04b10b7

Browse files
committed
Reformat Java template files
1 parent 97e2dee commit 04b10b7

8 files changed

Lines changed: 291 additions & 289 deletions

generator/templates/base_template.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@
2929
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030
* POSSIBILITY OF SUCH DAMAGE.
3131
*/
32-
package {{package_name}};
33-
{% for i in imports %}
34-
{%- if i != '' %}
35-
import {{i}};{{ '\n' if loop.last }}
36-
{%- else %}
37-
{{''}}
38-
{%- endif %}
39-
{%- endfor %}
40-
{%- if description is defined or since is defined or see is defined or deprecated is defined %}
32+
package
33+
34+
{{package_name}};
35+
{%for i in imports%}
36+
{%-if i!=''%}
37+
import {{i}};{{'\n'if loop.last}}
38+
{%-else%}
39+
{{''}}
40+
{%-endif%}
41+
{%-endfor%}
42+
{%-if description is defined or since is defined or see is defined or deprecated is defined%}
4143
/**
4244
{%- if description is defined %}
4345
{%- for d in description %}
@@ -63,13 +65,13 @@
6365
* <td>{%- for d in param.description %}{{d}}{%- endfor %}</td>
6466
* <td>{%- if param.mandatory is eq true %}Y{%- else %}N{%- endif %}</td>
6567
* <td>{%- for k in param.values %}{{ '{' if loop.first}}"{{k}}": {{param.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}</td>
66-
{%- if param.since is defined and param.since is not none %}{% set see, deprecated, since, history, spacing, headerParam = param.see, param.deprecated, param.since, param.history, ' * ', 'true' %}
68+
{%- if param.since is defined and param.since is not none %}{% set see, deprecated, since, history, spacing, headerParam = param.see, param.deprecated, param.since, param.history, ' * ', 'true' %}
6769
* <td>
68-
{%- include "javadoc_version_info.java" %}
70+
{%- include "javadoc_version_info.java" %}
6971
* </td>
70-
{%- else %}
72+
{%- else %}
7173
* <td></td>
72-
{%- endif %}
74+
{%- endif %}
7375
* </tr>
7476
{%- endfor %}
7577
* </table>
@@ -79,9 +81,9 @@
7981
{%- endif %}{% set prefix = ' * ' %}
8082
{%- include "javadoc_version_info.java" %}
8183
*/
82-
{%- endif %}
83-
{%- if deprecated is not none %}
84+
{%-endif%}
85+
{%-if deprecated is not none%}
8486
@Deprecated
85-
{%- endif %}
86-
{%- block body %}
87-
{% endblock -%}
87+
{%-endif%}
88+
{%-block body%}
89+
{%endblock-%}
Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
1-
{% extends "base_template.java" %}
2-
{% block body %}
3-
public enum {{class_name}} {
4-
{%- for param in params %}
5-
{%- if param.description is defined or param.since is defined %}
6-
/**
7-
{%- if param.description is defined %}
8-
{%- for d in param.description %}
9-
* {{d}}
10-
{%- endfor %}{% endif -%}
11-
{%- if param.description is defined and (param.since is defined or param.see is defined) %}
12-
*
13-
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = param.see, param.deprecated, param.since, param.history, ' ', ' * ' %}
14-
{%- include "javadoc_version_info.java" %}
15-
*/
16-
{%- endif %}
17-
{%- if param.deprecated is defined %}
18-
@Deprecated
19-
{%- endif %}
20-
{%- if kind == "simple" %}
21-
{{param.name}}{{ "," if not loop.last }}
22-
{%- elif kind == "custom" %}
23-
{{param.name}}({{param.internal}}){{ "," if not loop.last }}
24-
{%- endif %}
25-
{%- endfor %};
1+
{%extends"base_template.java"%}
2+
{%block body%}
3+
public enum {{class_name}}{
4+
{%-for param in params%}
5+
{%-if param.description is defined or param.since is defined%}
6+
/**
7+
{%- if param.description is defined %}
8+
{%- for d in param.description %}
9+
* {{d}}
10+
{%- endfor %}{% endif -%}
11+
{%- if param.description is defined and (param.since is defined or param.see is defined) %}
12+
*
13+
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = param.see, param.deprecated, param.since, param.history, ' ', ' * ' %}
14+
{%- include "javadoc_version_info.java" %}
15+
*/
16+
{%-endif%}
17+
{%-if param.deprecated is defined%}
18+
@Deprecated
19+
{%-endif%}
20+
{%-if kind=="simple"%}
21+
{{param.name}}{{","if not loop.last}}
22+
{%-elif kind=="custom"%}
23+
{{param.name}}({{param.internal}}){{","if not loop.last}}
24+
{%-endif%}
25+
{%-endfor%};
2626

27-
{%- if kind == "simple" %}
27+
{%-if kind=="simple"%}
2828

29-
/**
30-
* Convert String to {{class_name}}
31-
*
32-
* @param value String
33-
* @return {{class_name}}
34-
*/
35-
public static {{class_name}} valueForString(String value) {
36-
try {
37-
return valueOf(value);
38-
} catch (Exception e) {
39-
return null;
29+
/**
30+
* Convert String to {{class_name}}
31+
*
32+
* @param value String
33+
* @return {{class_name}}
34+
*/
35+
public static {{class_name}}valueForString(String value){
36+
try{
37+
return valueOf(value);
38+
}catch(Exception e){
39+
return null;
40+
}
4041
}
41-
}
42-
{%- elif kind == "custom" %}
42+
{%-elif kind=="custom"%}
4343

44-
private final String VALUE;
44+
private final String VALUE;
4545

46-
/**
47-
* Private constructor
48-
*/
49-
private {{class_name}}(String value) {
50-
this.VALUE = value;
51-
}
46+
/**
47+
* Private constructor
48+
*/
49+
private {{class_name}}(String value){
50+
this.VALUE=value;
51+
}
5252

53-
/**
54-
* Convert String to {{class_name}}
55-
*
56-
* @param value String
57-
* @return {{class_name}}
58-
*/
59-
public static {{class_name}} valueForString(String value) {
60-
if (value == null) {
61-
return null;
53+
/**
54+
* Convert String to {{class_name}}
55+
*
56+
* @param value String
57+
* @return {{class_name}}
58+
*/
59+
public static {{class_name}}valueForString(String value){
60+
if(value==null){
61+
return null;
6262
}
6363

64-
for ({{class_name}} anEnum : EnumSet.allOf({{class_name}}.class)) {
65-
if (anEnum.toString().equals(value)) {
66-
return anEnum;
67-
}
64+
for({{class_name}}anEnum:EnumSet.allOf({{class_name}}.class)){
65+
if(anEnum.toString().equals(value)){
66+
return anEnum;
67+
}
6868
}
6969
return null;
70-
}
70+
}
7171

72-
/**
73-
* Return String value of element
74-
*
75-
* @return String
76-
*/
77-
@Override
78-
public String toString() {
72+
/**
73+
* Return String value of element
74+
*
75+
* @return String
76+
*/
77+
@Override
78+
public String toString(){
7979
return VALUE;
80-
}
81-
{%- endif %}
82-
}
83-
{% endblock -%}
80+
}
81+
{%-endif%}
82+
}
83+
{%endblock-%}
Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
{% extends "struct_function_template.java" %}
1+
{%extends"struct_function_template.java"%}
22

3-
{%- block params %}
4-
{%- if params is defined %}
5-
{%- for p in params %}
6-
{%- 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, ' ', '/**', ' */', ' * ' %}
7-
{%- include "javadoc_version_info.java" %}
8-
{%- if p.deprecated is not none %}
9-
@Deprecated
10-
{%- endif %}
11-
public static final String {{p.key}} = "{{p.origin}}";
12-
{%- endif %}
13-
{%- endfor %}
14-
{%- endif %}
15-
{%- endblock %}
3+
{%-block params%}
4+
{%-if params is defined%}
5+
{%-for p in params%}
6+
{%-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,' ','/**',' */',' * '%}
7+
{%-include"javadoc_version_info.java"%}
8+
{%-if p.deprecated is not none%}
9+
@Deprecated
10+
{%-endif%}
11+
public static final String{{p.key}}="{{p.origin}}";
12+
{%-endif%}
13+
{%-endfor%}
14+
{%-endif%}
15+
{%-endblock%}
1616

17-
{%- block constructor_simple %}
18-
public {{class_name}}() {
17+
{%-block constructor_simple%}
18+
public {{class_name}}(){
1919
super(FunctionID.{{function_id}}.toString());
20-
}{% endblock -%}
20+
}{%endblock-%}
2121

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

26-
/**
27-
* Sets the {{p.origin}}.
28-
*
29-
{%- include "javadoc_template.java" %}
30-
*/
31-
{%- if p.deprecated is defined and p.deprecated is not none %}
32-
@Deprecated
33-
{%- endif %}
34-
public {{class_name}} set{{p.title}}({% if p.mandatory %}@NonNull {% endif %}{{p.return_type}} {{p.last}}) {
35-
setParameters({{p.key}}, {{p.last}});
26+
/**
27+
* Sets the {{p.origin}}.
28+
*
29+
{%- include "javadoc_template.java" %}
30+
*/
31+
{%-if p.deprecated is defined and p.deprecated is not none%}
32+
@Deprecated
33+
{%-endif%}
34+
public {{class_name}}set{{p.title}}({%if p.mandatory%}@NonNull {%endif%}{{p.return_type}}{{p.last}}){
35+
setParameters({{p.key}},{{p.last}});
3636
return this;
37-
}
37+
}
3838

39-
/**
40-
* Gets the {{p.origin}}.
41-
*
42-
{%- include "javadoc_return.java" %}
43-
*/
44-
{%- if p.SuppressWarnings is defined %}
45-
@SuppressWarnings("{{p.SuppressWarnings}}")
46-
{%- endif %}
47-
{%- if p.deprecated is defined and p.deprecated is not none %}
48-
@Deprecated
49-
{%- endif %}
50-
public {{p.return_type}} get{{p.title}}() {
51-
{%- if p.return_type in ['String', 'Boolean', 'Integer'] %}
39+
/**
40+
* Gets the {{p.origin}}.
41+
*
42+
{%- include "javadoc_return.java" %}
43+
*/
44+
{%-if p.SuppressWarnings is defined%}
45+
@SuppressWarnings("{{p.SuppressWarnings}}")
46+
{%-endif%}
47+
{%-if p.deprecated is defined and p.deprecated is not none%}
48+
@Deprecated
49+
{%-endif%}
50+
public {{p.return_type}}get{{p.title}}(){
51+
{%-if p.return_type in['String','Boolean','Integer']%}
5252
return get{{p.return_type}}({{p.key}});
53-
{%- elif p.return_type in ['Float'] %}
54-
Object object = getParameters({{p.key}});
53+
{%-elif p.return_type in['Float']%}
54+
Object object=getParameters({{p.key}});
5555
return SdlDataTypeConverter.objectToFloat(object);
56-
{%- elif p.return_type in ['Double'] %}
57-
Object object = getParameters({{p.key}});
56+
{%-elif p.return_type in['Double']%}
57+
Object object=getParameters({{p.key}});
5858
return SdlDataTypeConverter.objectToDouble(object);
59-
{%- else %}
60-
{%- set clazz = p.return_type %}
61-
{%- if p.return_type.startswith('List')%}{%set clazz = p.return_type[5:-1]%}{% endif %}
62-
return ({{p.return_type}}) getObject({{clazz}}.class, {{p.key}});
63-
{%- endif %}
64-
}
59+
{%-else%}
60+
{%-set clazz=p.return_type%}
61+
{%-if p.return_type.startswith('List')%}{%set clazz=p.return_type[5:-1]%}{%endif%}
62+
return({{p.return_type}})getObject({{clazz}}.class,{{p.key}});
63+
{%-endif%}
64+
}
6565

66-
{%- endif %}
67-
{%- endfor %}
68-
{%- endblock %}
66+
{%-endif%}
67+
{%-endfor%}
68+
{%-endblock%}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
{%- if p.description is defined %}
2-
{%- for d in p.description %}
3-
{%- if loop.index == 1 %}
4-
* @return {{p.return_type}} {{d}}
5-
{%- else %}
6-
* {{d}}
7-
{%- endif %}{%- endfor %}
8-
{%- else %}
9-
* @return {{p.return_type}}
10-
{%- endif %}
11-
{%- if p.values is defined and p.values %}
12-
* {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}
13-
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = p.see, p.deprecated, p.since, p.history, ' ', ' * ' %}
14-
{%- include "javadoc_version_info.java" %}
1+
{%-if p.description is defined%}
2+
{%-for d in p.description%}
3+
{%-if loop.index==1%}
4+
*@return{{p.return_type}}{{d}}
5+
{%-else%}
6+
*{{d}}
7+
{%-endif%}{%-endfor%}
8+
{%-else%}
9+
*@return{{p.return_type}}
10+
{%-endif%}
11+
{%-if p.values is defined and p.values%}
12+
*{%-for k in p.values%}{{' {'if loop.first}}"{{k}}":{{p.values[k]}}{{', 'if not loop.last else'}'}}{%-endfor%}
13+
{%-endif%}{%set see,deprecated,since,history,spacing,prefix=p.see,p.deprecated,p.since,p.history,' ',' * '%}
14+
{%-include"javadoc_version_info.java"%}

0 commit comments

Comments
 (0)