toSource method

String toSource()

Implementation

String toSource() {
  if (entities.length == 1) {
    return entities[0].entityName;
  }
  else if (entities.length == 0) {
    return '';
  }
  else {
    String result = "";
    int joinIdx = 0;
    for (int i = 0; i < entities.length; i += 2) {
      if (i >= entities.length - 1) {
        break;
      }
      if (result.length > 0) {
        result = "$result ";
      }
      String leftEntity = entities[i].entityName;
      String rightEntity = entities[i + 1].entityName;
      JoinType join = joins[joinIdx++];
      String joinName = join.name;
      String joinCri = formJoinCri(entities[i],entities[i+1]);

      result = "$result$leftEntity $joinName $rightEntity on $joinCri";
    }
    return result;
  }
}