StringBuilderUtil

Facilita o uso de StringBuilder.

  • gist: https://gist.github.com/drafa/d97b2563147a55baadea
  • métodos:
    • append (Object … obj): StringBuilder -> Permite a concatenação de objetos entre si, adicionando no final da string resultante
    • insert (Object … obj): StringBuilder -> Permite a concatenação de objetos entre si, adicionando no início da string resultante
/**
* Allows concatenation of objects to one another, adding at the end of the

* resulting string

* see {
@link StringBuilder#append(Object) StringBuilder.append(Object obj)}
*
@param obj
* @return a <code>StringBuilder</code> with all objects

* @author https://github.com/drafa

*/

public static StringBuilder append(Object... obj) {
if(obj==null) { return new StringBuilder("null"); }
StringBuilder sb = new StringBuilder();
int i=0, l=obj.length;
while(i<l) { sb.append(obj[i++]); }
return sb;
}
/**
* Allows concatenation of objects to one another, adding at the beginning

* of the resulting string

* @see {
@link StringBuilder#insert(Object) StringBuilder.insert(Object obj)}
*
@param obj
* @return a <code>StringBuilder</code> with all objects

* @author https://github.com/drafa

*/

public static StringBuilder insert(Object... obj) {
if(obj==null) { return new StringBuilder("null"); }
StringBuilder sb = new StringBuilder();
int zero=0, i=zero, l=obj.length;
while(i<l) { sb.insert(zero, obj[i++]); }
return sb;
}