Skip to content

Instantly share code, notes, and snippets.

@Keshava11
Created March 2, 2017 10:42
Show Gist options
  • Save Keshava11/6c57344a48646f515af77c327f716b6d to your computer and use it in GitHub Desktop.
Save Keshava11/6c57344a48646f515af77c327f716b6d to your computer and use it in GitHub Desktop.
Android Studio Setter template for member names starting with 'm' and 's' without 'm' and 's' in method name.
#set($paramName = $helper.getParamName($field, $project))
public ##
#if($field.modifierStatic)
static ##
#end
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($name.length() > 1 && ($StringUtil.startsWith($name, 'm') || $StringUtil.startsWith($name, 's')))
#set($name = $name.substring(1))
#if ($paramName.length() > 1 && ($StringUtil.startsWith($paramName, 'm') || $StringUtil.startsWith($paramName, 's')))
#set($paramName = "i"+$paramName.substring(1))
#end
#end
void set${name}($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
this.##
#else
$classname.##
#end
#end
$field.name = $paramName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment