001package org.hl7.fhir.r5.utils.sql;
002
003public class Column {
004
005  private String name;
006  private int length;
007  private String type;
008  private ColumnKind kind;
009  private boolean isColl;
010  private boolean duplicateReported;
011  
012  protected Column() {
013    super();
014  }
015
016  protected Column(String name, boolean isColl, String type, ColumnKind kind) {
017    super();
018    this.name = name;
019    this.isColl = isColl;
020    this.type = type;
021    this.kind = kind;
022  }
023  
024  public String getName() {
025    return name;
026  }
027  public int getLength() {
028    return length;
029  }
030  public ColumnKind getKind() {
031    return kind;
032  }
033
034  public void setName(String name) {
035    this.name = name;
036  }
037
038  public void setLength(int length) {
039    this.length = length;
040  }
041
042  public void setKind(ColumnKind kind) {
043    this.kind = kind;
044  }
045
046  public String getType() {
047    return type;
048  }
049
050  public void setType(String type) {
051    this.type = type;
052  }
053
054  public boolean isColl() {
055    return isColl;
056  }
057
058  public void setColl(boolean isColl) {
059    this.isColl = isColl;
060  }
061
062  public String diff(Column other) {
063    if (!name.equals(other.name)) {
064      return "Names differ: '"+name+"' vs '"+other.name+"'"; 
065    }
066    if (kind != ColumnKind.Null && other.kind != ColumnKind.Null) {
067      if (length != other.length) {
068        return "Lengths differ: '"+length+"' vs '"+other.length+"'"; 
069      }
070      if (kind != other.kind) {
071        return "Kinds differ: '"+kind+"' vs '"+other.kind+"'"; 
072      }
073      if (isColl != other.isColl) {
074        return "Collection status differs: '"+isColl+"' vs '"+other.isColl+"'"; 
075      }
076    } else if (kind == ColumnKind.Null) {
077      kind = other.kind;
078      length = other.length;
079      isColl = other.isColl;
080    }
081    return null;
082  }
083
084  public boolean isDuplicateReported() {
085    return duplicateReported;
086  }
087
088  public void setDuplicateReported(boolean duplicateReported) {
089    this.duplicateReported = duplicateReported;
090  }
091
092  @Override
093  public String toString() {
094    return "Column [name=" + name + ", length=" + length + ", type=" + type + ", kind=" + kind + ", isColl=" + isColl
095        + "]";
096  }
097  
098  
099}