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

import java.util.List;
import java.util.stream.Collectors;

import javax.validation.Valid;

import org.dbflute.intro.app.model.document.decomment.parts.DfDecoMapColumnPart;
import org.dbflute.intro.app.model.document.decomment.parts.DfDecoMapTablePart;
import org.lastaflute.web.validation.Required;

/**
 * @author hakiba
 * @author jflute
 * @author cabos
 */
public class DecommentPickupResult {

    // ===================================================================================
    //                                                                           Attribute
    //                                                                           =========
    @Valid
    @Required
    public List<TablePart> tables;

    // done hakiba move it under tables by jflute (2017/08/17)
    // done hakiba validator annotation (Required only) by jflute (2017/08/17)
    public static class TablePart {
        @Required
        public String tableName;
        @Valid
        @Required
        public List<ColumnPart> columns;

        public TablePart(DfDecoMapTablePart tablePart) {
            this.tableName = tablePart.getTableName();
            this.columns = tablePart.getColumns().stream().map(columnPart -> new ColumnPart(columnPart)).collect(Collectors.toList());
        }

        public static class ColumnPart {
            @Required
            public String columnName;
            @Valid
            @Required
            public List<PropertyPart> properties;

            public ColumnPart(DfDecoMapColumnPart columnPart) {
                this.columnName = columnPart.getColumnName();
                this.properties =
                    columnPart.getProperties().stream().map(property -> new PropertyPart(property)).collect(Collectors.toList());
            }

            // done hakiba PropertyPart by jflute (2017/08/17)
            public static class PropertyPart {
                @Required
                public String decomment;
                @Required
                public String databaseComment;
                @Required
                public String previousWholeComment;
                @Required
                public Long commentVersion;
                @Valid
                @Required
                public List<String> authorList;

                public PropertyPart(DfDecoMapColumnPart.ColumnPropertyPart property) {
                    this.decomment = property.getDecomment();
                    this.databaseComment = property.getDatabaseComment();
                    this.previousWholeComment = property.getPreviousWholeComment();
                    this.commentVersion = property.getCommentVersion();
                    this.authorList = property.getAuthorList();
                }
            }
        }
    }

    // ===================================================================================
    //                                                                         Constructor
    //                                                                         ===========
    public DecommentPickupResult(List<DfDecoMapTablePart> tableParts) {
        this.tables = tableParts.stream().map(tablePart -> new TablePart(tablePart)).collect(Collectors.toList());
    }
}

@@ -717,24 +717,42 @@
   =========%0A
+    /** tables */%0A
     @Valid%0A 
@@ -974,24 +974,64 @@
 TablePart %7B%0A
+        /** table name e.g. %22MEMBER%22 */%0A
         @Req
@@ -1065,24 +1065,47 @@
  tableName;%0A
+        /** columns */%0A
         @Val
@@ -1462,24 +1462,74 @@
 olumnPart %7B%0A
+            /** column name e.g. %22MEMBER_NAME%22 */%0A
             
@@ -1572,24 +1572,54 @@
 columnName;%0A
+            /** properties */%0A
             
@@ -2109,24 +2109,86 @@
 pertyPart %7B%0A
+                /** decomment e.g. %22edited column comment%22 */%0A
             
@@ -2234,32 +2234,96 @@
 ring decomment;%0A
+                /** database comment e.g. %22database comment%22 */%0A
                 
@@ -2371,32 +2371,108 @@
 atabaseComment;%0A
+                /** previous whole comment e.g. %22previous whole comment%22 */%0A
                 
@@ -2525,32 +2525,78 @@
 usWholeComment;%0A
+                /** comment version e.g. 3 */%0A
                 
@@ -2649,16 +2649,84 @@
 ersion;%0A
+                /** author list e.g. %5B%22cabos%22, %22hakiba%22, %22deco%22%5D */%0A
         

write java doc on DecommentPickupResult