diff options
author | Noah Stanford <noah@livio.io> | 2022-01-05 15:27:54 -0500 |
---|---|---|
committer | Noah Stanford <noah@livio.io> | 2022-01-05 15:27:54 -0500 |
commit | 04b10b712f49bfda07ad23178831b46545498495 (patch) | |
tree | 091d49106781044c17de88d6e7d498d14a1a26fb | |
parent | 97e2dee1004002aa66b04a1b315c38d0bbda9df7 (diff) | |
download | sdl_android-04b10b712f49bfda07ad23178831b46545498495.tar.gz |
Reformat Java template files
-rw-r--r-- | generator/templates/base_template.java | 38 | ||||
-rw-r--r-- | generator/templates/enum_template.java | 142 | ||||
-rw-r--r-- | generator/templates/function_template.java | 114 | ||||
-rw-r--r-- | generator/templates/javadoc_return.java | 28 | ||||
-rw-r--r-- | generator/templates/javadoc_template.java | 28 | ||||
-rw-r--r-- | generator/templates/javadoc_version_info.java | 46 | ||||
-rw-r--r-- | generator/templates/struct_function_template.java | 82 | ||||
-rw-r--r-- | generator/templates/struct_template.java | 102 |
8 files changed, 291 insertions, 289 deletions
diff --git a/generator/templates/base_template.java b/generator/templates/base_template.java index e2f44a2cf..556eb76be 100644 --- a/generator/templates/base_template.java +++ b/generator/templates/base_template.java @@ -29,15 +29,17 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package {{package_name}}; -{% for i in imports %} -{%- if i != '' %} -import {{i}};{{ '\n' if loop.last }} -{%- else %} -{{''}} -{%- endif %} -{%- endfor %} -{%- if description is defined or since is defined or see is defined or deprecated is defined %} +package + +{{package_name}}; + {%for i in imports%} + {%-if i!=''%} +import {{i}};{{'\n'if loop.last}} + {%-else%} + {{''}} + {%-endif%} + {%-endfor%} + {%-if description is defined or since is defined or see is defined or deprecated is defined%} /** {%- if description is defined %} {%- for d in description %} @@ -63,13 +65,13 @@ import {{i}};{{ '\n' if loop.last }} * <td>{%- for d in param.description %}{{d}}{%- endfor %}</td> * <td>{%- if param.mandatory is eq true %}Y{%- else %}N{%- endif %}</td> * <td>{%- for k in param.values %}{{ '{' if loop.first}}"{{k}}": {{param.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}</td> - {%- 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' %} + {%- 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' %} * <td> - {%- include "javadoc_version_info.java" %} + {%- include "javadoc_version_info.java" %} * </td> - {%- else %} + {%- else %} * <td></td> - {%- endif %} + {%- endif %} * </tr> {%- endfor %} * </table> @@ -79,9 +81,9 @@ import {{i}};{{ '\n' if loop.last }} {%- endif %}{% set prefix = ' * ' %} {%- include "javadoc_version_info.java" %} */ -{%- endif %} -{%- if deprecated is not none %} + {%-endif%} + {%-if deprecated is not none%} @Deprecated -{%- endif %} -{%- block body %} -{% endblock -%} +{%-endif%} + {%-block body%} + {%endblock-%} diff --git a/generator/templates/enum_template.java b/generator/templates/enum_template.java index 72b88494e..29c6bed85 100644 --- a/generator/templates/enum_template.java +++ b/generator/templates/enum_template.java @@ -1,83 +1,83 @@ -{% extends "base_template.java" %} -{% block body %} -public enum {{class_name}} { - {%- for param in params %} - {%- if param.description is defined or param.since is defined %} - /** - {%- if param.description is defined %} - {%- for d in param.description %} - * {{d}} - {%- endfor %}{% endif -%} - {%- if param.description is defined and (param.since is defined or param.see is defined) %} - * - {%- endif %}{% set see, deprecated, since, history, spacing, prefix = param.see, param.deprecated, param.since, param.history, ' ', ' * ' %} - {%- include "javadoc_version_info.java" %} - */ - {%- endif %} - {%- if param.deprecated is defined %} - @Deprecated - {%- endif %} - {%- if kind == "simple" %} - {{param.name}}{{ "," if not loop.last }} - {%- elif kind == "custom" %} - {{param.name}}({{param.internal}}){{ "," if not loop.last }} - {%- endif %} - {%- endfor %}; +{%extends"base_template.java"%} + {%block body%} +public enum {{class_name}}{ + {%-for param in params%} + {%-if param.description is defined or param.since is defined%} + /** + {%- if param.description is defined %} + {%- for d in param.description %} + * {{d}} + {%- endfor %}{% endif -%} + {%- if param.description is defined and (param.since is defined or param.see is defined) %} + * + {%- endif %}{% set see, deprecated, since, history, spacing, prefix = param.see, param.deprecated, param.since, param.history, ' ', ' * ' %} + {%- include "javadoc_version_info.java" %} + */ + {%-endif%} + {%-if param.deprecated is defined%} +@Deprecated + {%-endif%} + {%-if kind=="simple"%} + {{param.name}}{{","if not loop.last}} + {%-elif kind=="custom"%} + {{param.name}}({{param.internal}}){{","if not loop.last}} + {%-endif%} + {%-endfor%}; - {%- if kind == "simple" %} + {%-if kind=="simple"%} - /** - * Convert String to {{class_name}} - * - * @param value String - * @return {{class_name}} - */ - public static {{class_name}} valueForString(String value) { - try { - return valueOf(value); - } catch (Exception e) { - return null; +/** + * Convert String to {{class_name}} + * + * @param value String + * @return {{class_name}} + */ +public static {{class_name}}valueForString(String value){ + try{ + return valueOf(value); + }catch(Exception e){ + return null; + } } - } - {%- elif kind == "custom" %} + {%-elif kind=="custom"%} - private final String VALUE; +private final String VALUE; - /** - * Private constructor - */ - private {{class_name}}(String value) { - this.VALUE = value; - } +/** + * Private constructor + */ +private {{class_name}}(String value){ + this.VALUE=value; + } - /** - * Convert String to {{class_name}} - * - * @param value String - * @return {{class_name}} - */ - public static {{class_name}} valueForString(String value) { - if (value == null) { - return null; +/** + * Convert String to {{class_name}} + * + * @param value String + * @return {{class_name}} + */ +public static {{class_name}}valueForString(String value){ + if(value==null){ + return null; } - for ({{class_name}} anEnum : EnumSet.allOf({{class_name}}.class)) { - if (anEnum.toString().equals(value)) { - return anEnum; - } + for({{class_name}}anEnum:EnumSet.allOf({{class_name}}.class)){ + if(anEnum.toString().equals(value)){ + return anEnum; + } } return null; - } + } - /** - * Return String value of element - * - * @return String - */ - @Override - public String toString() { +/** + * Return String value of element + * + * @return String + */ +@Override +public String toString(){ return VALUE; - } - {%- endif %} -} -{% endblock -%}
\ No newline at end of file + } + {%-endif%} + } + {%endblock-%}
\ No newline at end of file diff --git a/generator/templates/function_template.java b/generator/templates/function_template.java index 96ac7cf99..3c153639e 100644 --- a/generator/templates/function_template.java +++ b/generator/templates/function_template.java @@ -1,68 +1,68 @@ -{% extends "struct_function_template.java" %} +{%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 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}}() { + {%-block constructor_simple%} +public {{class_name}}(){ super(FunctionID.{{function_id}}.toString()); - }{% endblock -%} + }{%endblock-%} - {%- block setter %} - {%- for p in params|rejectattr('name') %} - {%- if p.origin not in ('success', 'resultCode', 'info') or kind != "response" %} + {%-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}}); + /** + * 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'] %} + /** + * 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}}); + {%-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}}); + {%-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 %} - } + {%-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 %}
\ No newline at end of file + {%-endif%} + {%-endfor%} + {%-endblock%}
\ No newline at end of file diff --git a/generator/templates/javadoc_return.java b/generator/templates/javadoc_return.java index debd19e0a..944915f8f 100644 --- a/generator/templates/javadoc_return.java +++ b/generator/templates/javadoc_return.java @@ -1,14 +1,14 @@ - {%- if p.description is defined %} - {%- for d in p.description %} - {%- if loop.index == 1 %} - * @return {{p.return_type}} {{d}} - {%- else %} - * {{d}} - {%- endif %}{%- endfor %} - {%- else %} - * @return {{p.return_type}} - {%- endif %} - {%- if p.values is defined and p.values %} - * {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %} - {%- endif %}{% set see, deprecated, since, history, spacing, prefix = p.see, p.deprecated, p.since, p.history, ' ', ' * ' %} - {%- include "javadoc_version_info.java" %}
\ No newline at end of file +{%-if p.description is defined%} + {%-for d in p.description%} + {%-if loop.index==1%} + *@return{{p.return_type}}{{d}} + {%-else%} + *{{d}} + {%-endif%}{%-endfor%} + {%-else%} + *@return{{p.return_type}} + {%-endif%} + {%-if p.values is defined and p.values%} + *{%-for k in p.values%}{{' {'if loop.first}}"{{k}}":{{p.values[k]}}{{', 'if not loop.last else'}'}}{%-endfor%} + {%-endif%}{%set see,deprecated,since,history,spacing,prefix=p.see,p.deprecated,p.since,p.history,' ',' * '%} + {%-include"javadoc_version_info.java"%}
\ No newline at end of file diff --git a/generator/templates/javadoc_template.java b/generator/templates/javadoc_template.java index 66a902fdb..797386533 100644 --- a/generator/templates/javadoc_template.java +++ b/generator/templates/javadoc_template.java @@ -1,14 +1,14 @@ - {%- if p.description is defined %} - {%- for d in p.description %} - {%- if loop.index == 1 %} - * @param {{p.last}} {{d}} - {%- else %} - * {{d}} - {%- endif %}{%- endfor %} - {%- else %} - * @param {{p.last}} - {%- endif %} - {%- if p.values is defined and p.values %} - * {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %} - {%- endif %}{% set see, deprecated, since, history, spacing, prefix = p.see, p.deprecated, p.since, p.history, ' ', ' * ' %} - {%- include "javadoc_version_info.java" %}
\ No newline at end of file +{%-if p.description is defined%} + {%-for d in p.description%} + {%-if loop.index==1%} + *@param {{p.last}}{{d}} + {%-else%} + *{{d}} + {%-endif%}{%-endfor%} + {%-else%} + *@param {{p.last}} + {%-endif%} + {%-if p.values is defined and p.values%} + *{%-for k in p.values%}{{' {'if loop.first}}"{{k}}":{{p.values[k]}}{{', 'if not loop.last else'}'}}{%-endfor%} + {%-endif%}{%set see,deprecated,since,history,spacing,prefix=p.see,p.deprecated,p.since,p.history,' ',' * '%} + {%-include"javadoc_version_info.java"%}
\ No newline at end of file diff --git a/generator/templates/javadoc_version_info.java b/generator/templates/javadoc_version_info.java index 0eabb1bd2..69451a922 100644 --- a/generator/templates/javadoc_version_info.java +++ b/generator/templates/javadoc_version_info.java @@ -1,23 +1,23 @@ -{%- if since is defined and since is not none %} -{%- if begin is defined %} -{{spacing}}{{begin}} -{%- endif %} -{%- if deprecated is defined and deprecated is not none %} -{{spacing}}{{prefix}}@since SmartDeviceLink {{history[0].since}} -{%- if headerParam is defined and headerParam is not none %} -{{spacing}}{{prefix}}@property-deprecated in SmartDeviceLink {{since}} -{%- else %} -{{spacing}}{{prefix}}@deprecated in SmartDeviceLink {{since}} -{%- endif %} -{%- elif history is defined and history is not none %} -{{spacing}}{{prefix}}@since SmartDeviceLink {{history[0].since}} -{%- else %} -{{spacing}}{{prefix}}@since SmartDeviceLink {{since}} -{%- endif %} -{%- if see is defined %} -{{spacing}}{{prefix}}@see {{see}} -{%- endif %} -{%- if end is defined %} -{{spacing}}{{end}} -{%- endif %} -{%- endif %}
\ No newline at end of file +{%-if since is defined and since is not none%} + {%-if begin is defined%} + {{spacing}}{{begin}} + {%-endif%} + {%-if deprecated is defined and deprecated is not none%} + {{spacing}}{{prefix}}@since SmartDeviceLink{{history[0].since}} + {%-if headerParam is defined and headerParam is not none%} + {{spacing}}{{prefix}}@property-deprecated in SmartDeviceLink{{since}} + {%-else%} + {{spacing}}{{prefix}}@deprecated in SmartDeviceLink{{since}} + {%-endif%} + {%-elif history is defined and history is not none%} + {{spacing}}{{prefix}}@since SmartDeviceLink{{history[0].since}} + {%-else%} + {{spacing}}{{prefix}}@since SmartDeviceLink{{since}} + {%-endif%} + {%-if see is defined%} + {{spacing}}{{prefix}}@see {{see}} + {%-endif%} + {%-if end is defined%} + {{spacing}}{{end}} + {%-endif%} + {%-endif%}
\ No newline at end of file diff --git a/generator/templates/struct_function_template.java b/generator/templates/struct_function_template.java index a0ab096f9..9eea20285 100644 --- a/generator/templates/struct_function_template.java +++ b/generator/templates/struct_function_template.java @@ -1,49 +1,49 @@ -{% extends "base_template.java" %} +{%extends"base_template.java"%} -{% block body %} -public class {{class_name}} extends {{extends_class}} { - {%- block params %} - {%- endblock %} + {%block body%} +public class {{class_name}}extends{{extends_class}}{ + {%-block params%} + {%-endblock%} - /** - * Constructs a new {{class_name}} object - */ - {%- block constructor_simple %} - {% endblock %} + /** + * Constructs a new {{class_name}} object + */ + {%-block constructor_simple%} + {%endblock%} - /** - * Constructs a new {{class_name}} object indicated by the Hashtable parameter - * - * @param hash The Hashtable to use - */ - public {{class_name}}(Hashtable<String, Object> hash) { +/** + * Constructs a new {{class_name}} object indicated by the Hashtable parameter + * + * @param hash The Hashtable to use + */ +public {{class_name}}(Hashtable<String, Object> hash){ super(hash); - } - {%- if params is defined %} - {%- set constructor = [] %} - {%- for p in params|selectattr('mandatory') %}{{ constructor.append('@NonNull ' + p.return_type + ' ' + p.last) or '' }} - {%- endfor %} - {%- if constructor|length > 0 %} + } + {%-if params is defined%} + {%-set constructor=[]%} + {%-for p in params|selectattr('mandatory')%}{{constructor.append('@NonNull '+p.return_type+' '+p.last)or''}} + {%-endfor%} + {%-if constructor|length>0%} - /** - * Constructs a new {{class_name}} object - * - {%- for p in params|selectattr('mandatory') %} - {%- include "javadoc_template.java" %} - {%- endfor %} - */ - public {{class_name}}({{ constructor|join(', ') }}) { +/** + * Constructs a new {{class_name}} object + * + {%- for p in params|selectattr('mandatory') %} + {%- include "javadoc_template.java" %} + {%- endfor %} + */ +public {{class_name}}({{constructor|join(', ')}}){ this(); - {%- for p in params|selectattr('mandatory') %} + {%-for p in params|selectattr('mandatory')%} set{{p.title}}({{p.last}}); - {%- endfor %} - } - {%- endif %} - {%- endif %} + {%-endfor%} + } + {%-endif%} + {%-endif%} - {%- if params is defined %} - {%- block setter %} - {%- endblock%} - {%- endif %} -} -{% endblock -%} + {%-if params is defined%} + {%-block setter%} + {%-endblock%} + {%-endif%} + } + {%endblock-%} diff --git a/generator/templates/struct_template.java b/generator/templates/struct_template.java index 5fcca3ba9..4e5a2b4f4 100644 --- a/generator/templates/struct_template.java +++ b/generator/templates/struct_template.java @@ -1,61 +1,61 @@ -{% extends "struct_function_template.java" %} +{%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 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 constructor_simple%} +public {{class_name}}(){} + {%-endblock-%} - {%- block setter %} - {%- for p in params|rejectattr('name') %} + {%-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}}); + /** + * 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'] %} + /** + * 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}}); + {%-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 %} - } + {%-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 %} + {%-endfor%} + {%-endblock%} |