templates.java.method.txt Maven / Gradle / Ivy
/**
* {{comment}}
* {{group}}
*
{{#arguments}}
* @param {{name}}
{{/arguments}}
* @return {{reply}}
*/
public {{$return}}{{reply}}{{/return}} {{methodname}}({{#arguments}}{{^first}}, {{/first}}{{typename}}{{#multiple}}[]{{/multiple}} {{name}}{{/arguments}}) throws RedisException {
if (version < {{name}}_VERSION) throw new RedisException("Server does not support {{name}}");
{{#usearray}}
List list = new ArrayList();
{{#arguments}}
{{#multiple}}
Collections.addAll(list, {{name}});
{{/multiple}}
{{^multiple}}
{{^optional}}
list.add({{name}});
{{/optional}}
{{#optional}}
if ({{name}} != null) list.add({{name}});
{{/optional}}
{{/multiple}}
{{/arguments}}
return ({{$return}}{{reply}}{{/return}}) {{$method}}method{{/method}}({{name}}, new Command({{name}}_BYTES, {{#split_command}}{{name}}2_BYTES, {{/split_command}}list.toArray(new Object[list.size()])));
{{/usearray}}
{{^usearray}}
return ({{$return}}{{reply}}{{/return}}) {{$method}}method{{/method}}({{name}}, new Command({{name}}_BYTES{{#split_command}}, {{name}}2_BYTES{{/split_command}}{{#arguments}}, {{name}}{{/arguments}}));
{{/usearray}}
}
{{#varargs}}
// Varargs version to simplify commands with optional or multiple arguments
public {{$return}}{{reply}}{{/return}} {{methodname}}_(Object... arguments) throws RedisException {
if (version < {{name}}_VERSION) throw new RedisException("Server does not support {{name}}");
return ({{$return}}{{reply}}{{/return}}) {{$method}}method{{/method}}({{name}}, new Command({{name}}_BYTES, {{#split_command}}{{name}}2_BYTES, {{/split_command}}arguments));
}
{{/varargs}}