SHARE
TWEET

Untitled

a guest Jul 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Available context bindings:
  3.  *   COLUMNS     List<DataColumn>
  4.  *   ROWS        Iterable<DataRow>
  5.  *   OUT         { append() }
  6.  *   FORMATTER   { format(row, col); formatValue(Object, col) }
  7.  *   TRANSPOSED  Boolean
  8.  * plus ALL_COLUMNS, TABLE, DIALECT
  9.  *
  10.  * where:
  11.  *   DataRow     { rowNumber(); first(); last(); data(): List<Object>; value(column): Object }
  12.  *   DataColumn  { columnNumber(), name() }
  13.  */
  14.  
  15. def toCamelCase( String text ) {
  16.     text = text.replaceAll( "(_)([A-Za-z0-9])", { Object[] it -> it[2].toUpperCase() } )
  17.     // return capitalize(text)
  18.     return text.capitalize()
  19. }
  20.  
  21.  OUT.append("type Test struct {\n")
  22.  
  23.  COLUMNS.eachWithIndex { col, i ->
  24.     OUT.append("\t" + toCamelCase(col.name()) + "\t`db:\"" + col.name() + "\"`\n")
  25. }
  26.  
  27. OUT.append("}")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top