Last active
August 29, 2015 14:04
-
-
Save Aracem/e58d3e8c6210cb72f12e to your computer and use it in GitHub Desktop.
An Android Studio template to generate utils methods for Beans that contains a List of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Declaration: Java - Declaration | |
* Variables: | |
* $TYPE$ expresion: arrayValue() defaultValue: listField | |
* $OBJECT$ expresion:className() defaultValue: Object | |
* | |
* Follow this instruction to add it to Android Studio | |
* http://dmytrodanylyk.com/pages/blog/templates.html | |
*/ | |
/** | |
* Returns the size of the list or 0 if null or empty | |
*/ | |
public int size() { | |
return $TYPE$ == null ? 0 : $TYPE$.size(); | |
} | |
/** | |
* @return true when the list is empty | |
*/ | |
public boolean isEmpty() { | |
return size() == 0; | |
} | |
/** | |
* Adds a $OBJECT$ to the list | |
*/ | |
public void add$OBJECT$($OBJECT$ object){ | |
if($TYPE$ != null){ | |
$TYPE$.add(object); | |
} | |
} | |
/** | |
* Gets a $OBJECT$ from list | |
*/ | |
public $OBJECT$ get$OBJECT$(int position){ | |
return $TYPE$.size() > position ? $TYPE$.get(position) : null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment