package org.dbflute.intro.app.model.document.decomment;

import static org.dbflute.intro.mylasta.appcls.AppCDef.PieceTargetType;

import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.dbflute.helper.mapstring.MapListString;

/**
 * @author hakiba
 * @author cabos
 */
public class DfDecoMapPiece {

    // ===================================================================================
    //                                                                          Definition
    //                                                                          ==========
    private static String DEFAULT_FORMAT_VERSION = "1.0";

    // ===================================================================================
    //                                                                           =========
    //                                                                           Attribute
    protected boolean merged;
    protected String tableName;
    protected String columnName;
    protected PieceTargetType targetType;
    protected String decomment;
    protected String databaseComment;
    protected Long commentVersion;
    protected List<String> authorList;
    protected String pieceCode;
    protected LocalDateTime pieceDatetime;
    protected String pieceOwner;
    protected List<String> previousPieceList;
    protected String formatVersion = DEFAULT_FORMAT_VERSION;

    // done cabos move to before accessor by jflute (2017/08/10)
    // ===================================================================================
    //                                                                           Converter
    //                                                                           =========
    // TODO yuto write e.g. (2017/11/11)
    public Map<String, Object> convertMap() {
        // done cabos Map by jflute (2017/08/10)
        // done cabos use Linked by jflute (2017/09/07)
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("merged", this.merged);
        map.put("tableName", this.tableName);
        map.put("columnName", this.columnName);
        map.put("decomment", this.decomment);
        map.put("databaseComment", this.databaseComment);
        map.put("commentVersion", this.commentVersion);
        map.put("authorList", this.authorList);
        map.put("pieceCode", this.pieceCode);
        map.put("pieceDatetime", this.pieceDatetime);
        map.put("pieceOwner", this.pieceOwner);
        map.put("previousPieceList", this.previousPieceList);
        map.put("formatVersion", this.formatVersion);
        return map;
    }

    // ===================================================================================
    //                                                                            Override
    //                                                                            ========
    @Override
    public String toString() {
        return new MapListString().buildMapString(this.convertMap());
    }

    // ===================================================================================
    //                                                                            Accessor
    //                                                                            ========
    public void setMerged(boolean merged) {
        this.merged = merged;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public void setTargetType(PieceTargetType targetType) {
        this.targetType = targetType;
    }

    public void setDecomment(String decomment) {
        this.decomment = decomment;
    }

    public void setDatabaseComment(String databaseComment) {
        this.databaseComment = databaseComment;
    }

    public void setCommentVersion(Long commentVersion) {
        this.commentVersion = commentVersion;
    }

    public void setAuthorList(List<String> authorList) {
        this.authorList = authorList;
    }

    public void setPieceCode(String pieceCode) {
        this.pieceCode = pieceCode;
    }

    public void setPieceDatetime(LocalDateTime pieceDatetime) {
        this.pieceDatetime = pieceDatetime;
    }

    public void setPieceOwner(String pieceOwner) {
        this.pieceOwner = pieceOwner;
    }

    public void setPreviousPieceList(List<String> previousPieceList) {
        this.previousPieceList = previousPieceList;
    }

    public boolean isMerged() {
        return merged;
    }

    public String getTableName() {
        return tableName;
    }

    public String getColumnName() {
        return columnName;
    }

    public PieceTargetType getTargetType() {
        return targetType;
    }

    public String getDecomment() {
        return decomment;
    }

    public String getDatabaseComment() {
        return databaseComment;
    }

    public Long getCommentVersion() {
        return commentVersion;
    }

    public List<String> getAuthorList() {
        return authorList;
    }

    public String getPieceCode() {
        return pieceCode;
    }

    public LocalDateTime getPieceDatetime() {
        return pieceDatetime;
    }

    public String getPieceOwner() {
        return pieceOwner;
    }

    public List<String> getPreviousPieceList() {
        return previousPieceList;
    }

    public String getFormatVersion() {
        return formatVersion;
    }
}

@@ -534,25 +534,26 @@
     
-Definition
+ Attribute
 %0A    //
+ 
     
@@ -635,341 +635,44 @@
 ====
-=
 %0A    pr
-ivate static String DEFAULT_FORMAT_VERSION = %221.0%22;%0A%0A    // ===================================================================================%0A    //                                                                           =========%0A    //                                                                           Attribute
+otected String formatVersion;
 %0A   
@@ -1106,69 +1106,8 @@
 ist;
-%0A    protected String formatVersion = DEFAULT_FORMAT_VERSION;
 %0A%0A  
@@ -1691,16 +1691,70 @@
 ap%3C%3E();%0A
+        map.put(%22formatVersion%22, this.formatVersion);%0A
         
@@ -2301,62 +2301,8 @@
 t);%0A
-        map.put(%22formatVersion%22, this.formatVersion);%0A
     
@@ -2988,24 +2988,132 @@
    ========%0A
+    public void setFormatVersion(String formatVersion) %7B%0A        this.formatVersion = formatVersion;%0A    %7D%0A%0A
     public v
@@ -4319,32 +4319,108 @@
 eceList;%0A    %7D%0A%0A
+    public String getFormatVersion() %7B%0A        return formatVersion;%0A    %7D%0A%0A
     public boole
@@ -5295,83 +5295,7 @@
    %7D
-%0A%0A    public String getFormatVersion() %7B%0A        return formatVersion;%0A    %7D
 %0A%7D%0A

move format version field