All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rrsunhome.excelsql.SqlDefinition Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package com.github.rrsunhome.excelsql;

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

/**
 * @author : qijia.wang
 * create at:  2020/3/31  下午4:03
 */
public class SqlDefinition {

    private String tableName;

    private List rowDefinitions;

    public SqlDefinition(String tableName, List rowDefinitions) {
        this.tableName = tableName;
        this.rowDefinitions = rowDefinitions;
    }

    public SqlDefinition(String tableName) {
        this.tableName = tableName;
        this.rowDefinitions = new ArrayList<>();
    }


    public static class RowDefinition {
        private List fieldDefinitions = new ArrayList<>();

        public RowDefinition() {
        }

        public RowDefinition(List fieldDefinitions) {
            this.fieldDefinitions = fieldDefinitions;
        }

        public List getFieldDefinitions() {
            return fieldDefinitions;
        }

        public void setFieldDefinitions(List fieldDefinitions) {
            this.fieldDefinitions = fieldDefinitions;
        }

        public void addCellDefinition(String field, String fieldValue) {
            fieldDefinitions.add(new FieldDefinition(field, fieldValue));
        }

        public void addCellDefinition(String field, String fieldValue, boolean isCondition) {
            fieldDefinitions.add(new FieldDefinition(field, fieldValue, isCondition));
        }

        public List getFields() {
            List list = fieldDefinitions.stream()
                    .map(x -> x.getField())
                    .collect(Collectors.toList());
            return list;

        }

        public List getFieldValues() {
            List list = fieldDefinitions.stream()
                    .map(x -> x.getFieldValue())
                    .collect(Collectors.toList());
            return list;

        }
    }


    public static class FieldDefinition {

        private String field;

        private String fieldValue;

        private boolean isCondition;

        public FieldDefinition(String field, String fieldValue) {
            this.field = field;
            this.fieldValue = fieldValue;
        }

        public FieldDefinition(String field, String fieldValue, boolean isCondition) {
            this.field = field;
            this.fieldValue = fieldValue;
            this.isCondition = isCondition;
        }

        public String getField() {
            return field;
        }

        public String getFieldValue() {
            return fieldValue;
        }

        public boolean isCondition() {
            return isCondition;
        }

        public void setCondition(boolean condition) {
            isCondition = condition;
        }
    }

    public String getTableName() {
        return tableName;
    }

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

    public List getRowDefinitions() {
        return rowDefinitions;
    }

    public void setRowDefinitions(List rowDefinitions) {
        this.rowDefinitions = rowDefinitions;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy