package util.sqlparse.visitor.common.bean;

import java.util.ArrayList;
import java.util.List;
import util.sqlparse.visitor.common.memo.ValueMemo;

public class ValueInfo extends ValueMemo {
   private List<FieldInfo> fields;

   public ValueInfo() {
      this.fields = new ArrayList();
   }

   public ValueInfo(ValueMemo x) {
      this.field = x.field;
      this.value = x.value;
      this.ref = x.ref;
      this.expr = x.expr;
      this.refMongo = x.refMongo;
      this.nodeMongo = x.nodeMongo;
      this.sequence = x.sequence;
      this.operator = x.operator;
      this.isPreDefined = x.isPreDefined;
   }

   public List<FieldInfo> getFields() {
      return this.fields;
   }

   public void setFields(List<FieldInfo> fields) {
      this.fields = fields;
   }

   public String getValueNames() {
      if (this.fields.size() == 0) {
         return this.field.getAtomName();
      } else {
         StringBuilder sb = new StringBuilder();

         for(FieldInfo fieldInfo : this.fields) {
            for(String s : fieldInfo.getAtomName()) {
               sb.append(s).append(".");
            }
         }

         return sb.toString();
      }
   }
}
