package com.ruoyi.web.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.common.collect.Maps;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;

import java.util.List;
import java.util.Map;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DynamicTable<T, V> {
    String name;
    List<String> columns;
    List<T> rows = Lists.newArrayList();
    Map<String, V> options;

    public void appendRow(T row) {
        rows.add(row);
    }

    public V addOption(String name, V value) {
        if (null == options) {
            options = Maps.newHashMap();
        }
        return options.put(name, value);
    }
}
