package com.alibaba.druid.wall;

import com.alibaba.druid.support.monitor.annotation.AggregateType;
import com.alibaba.druid.support.monitor.annotation.MField;
import com.alibaba.druid.support.monitor.annotation.MTable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@MTable(
   name = "druid_wall"
)
public class WallProviderStatValue {
   @MField(
      aggregate = AggregateType.None
   )
   private String name;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long checkCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long hardCheckCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long violationCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long whiteListHitCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long blackListHitCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long syntaxErrorCount;
   @MField(
      aggregate = AggregateType.Sum
   )
   private long violationEffectRowCount;
   private final List<WallTableStatValue> tables = new ArrayList();
   private final List<WallFunctionStatValue> functions = new ArrayList();
   private final List<WallSqlStatValue> whiteList = new ArrayList();
   private final List<WallSqlStatValue> blackList = new ArrayList();

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public long getCheckCount() {
      return this.checkCount;
   }

   public void setCheckCount(long checkCount) {
      this.checkCount = checkCount;
   }

   public long getHardCheckCount() {
      return this.hardCheckCount;
   }

   public void setHardCheckCount(long hardCheckCount) {
      this.hardCheckCount = hardCheckCount;
   }

   public long getViolationCount() {
      return this.violationCount;
   }

   public void setViolationCount(long violationCount) {
      this.violationCount = violationCount;
   }

   public long getWhiteListHitCount() {
      return this.whiteListHitCount;
   }

   public void setWhiteListHitCount(long whiteListHitCount) {
      this.whiteListHitCount = whiteListHitCount;
   }

   public long getBlackListHitCount() {
      return this.blackListHitCount;
   }

   public void setBlackListHitCount(long blackListHitCount) {
      this.blackListHitCount = blackListHitCount;
   }

   public long getSyntaxErrorCount() {
      return this.syntaxErrorCount;
   }

   public void setSyntaxErrorCount(long syntaxErrorCount) {
      this.syntaxErrorCount = syntaxErrorCount;
   }

   public long getViolationEffectRowCount() {
      return this.violationEffectRowCount;
   }

   public void setViolationEffectRowCount(long violationEffectRowCount) {
      this.violationEffectRowCount = violationEffectRowCount;
   }

   public List<WallTableStatValue> getTables() {
      return this.tables;
   }

   public List<WallFunctionStatValue> getFunctions() {
      return this.functions;
   }

   public List<WallSqlStatValue> getWhiteList() {
      return this.whiteList;
   }

   public List<WallSqlStatValue> getBlackList() {
      return this.blackList;
   }

   public Map<String, Object> toMap() {
      Map<String, Object> info = new LinkedHashMap();
      info.put("checkCount", this.getCheckCount());
      info.put("hardCheckCount", this.getHardCheckCount());
      info.put("violationCount", this.getViolationCount());
      info.put("violationEffectRowCount", this.getViolationEffectRowCount());
      info.put("blackListHitCount", this.getBlackListHitCount());
      info.put("blackListSize", this.getBlackList().size());
      info.put("whiteListHitCount", this.getWhiteListHitCount());
      info.put("whiteListSize", this.getWhiteList().size());
      info.put("syntaxErrorCount", this.getSyntaxErrorCount());
      List<Map<String, Object>> tables = new ArrayList(this.tables.size());

      for(WallTableStatValue tableStatValue : this.tables) {
         Map<String, Object> statMap = tableStatValue.toMap();
         tables.add(statMap);
      }

      info.put("tables", tables);
      tables = new ArrayList();

      for(WallFunctionStatValue funStatValue : this.functions) {
         Map<String, Object> statMap = funStatValue.toMap();
         tables.add(statMap);
      }

      info.put("functions", tables);
      tables = new ArrayList(this.blackList.size());

      for(WallSqlStatValue sqlStatValue : this.blackList) {
         tables.add(sqlStatValue.toMap());
      }

      info.put("blackList", tables);
      tables = new ArrayList(this.whiteList.size());

      for(WallSqlStatValue sqlStatValue : this.whiteList) {
         tables.add(sqlStatValue.toMap());
      }

      info.put("whiteList", tables);
      return info;
   }
}
