package pers.zr.opensource.magic.dao.action;

import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;

import java.util.List;

/**
 * Created by zhurong on 2016-4-28.
 */
public class ActionTable {

    /** table name*/
    private String tableName;

    /** keys*/
    private List<String> keys;

    private List<String> columns;

    private List<String> defaultInsertColumns;

    private List<String> defaultUpdateColumns;

    private TableShardStrategy tableShardStrategy;

    private TableShardHandler tableShardHandler;

    public String getTableName() {
        return tableName;
    }

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

    public List<String> getKeys() {
        return keys;
    }

    public void setKeys(List<String> keys) {
        this.keys = keys;
    }

    public List<String> getColumns() {
        return columns;
    }

    public void setColumns(List<String> columns) {
        this.columns = columns;
    }

    public TableShardStrategy getTableShardStrategy() {
        return tableShardStrategy;
    }

    public void setTableShardStrategy(TableShardStrategy tableShardStrategy) {
        this.tableShardStrategy = tableShardStrategy;
    }

    public TableShardHandler getTableShardHandler() {
        return tableShardHandler;
    }

    public void setTableShardHandler(TableShardHandler tableShardHandler) {
        this.tableShardHandler = tableShardHandler;
    }

    public List<String> getDefaultInsertColumns() {
        return defaultInsertColumns;
    }

    public void setDefaultInsertColumns(List<String> defaultInsertColumns) {
        this.defaultInsertColumns = defaultInsertColumns;
    }

    public List<String> getDefaultUpdateColumns() {
        return defaultUpdateColumns;
    }

    public void setDefaultUpdateColumns(List<String> defaultUpdateColumns) {
        this.defaultUpdateColumns = defaultUpdateColumns;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ActionTable that = (ActionTable) o;

        if (!tableName.equals(that.tableName)) return false;
        if (!keys.equals(that.keys)) return false;
        if (!columns.equals(that.columns)) return false;
        return tableShardStrategy.equals(that.tableShardStrategy);

    }

    @Override
    public int hashCode() {
        int result = tableName.hashCode();
        result = 31 * result + keys.hashCode();
        result = 31 * result + columns.hashCode();
        result = 31 * result + tableShardStrategy.hashCode();
        return result;
    }
}

@@ -185,16 +185,42 @@
 il.List;
+%0Aimport java.util.Objects;
 %0A%0A/**%0A *
@@ -2015,32 +2015,33 @@
 Columns;%0A    %7D%0A%0A
+%0A
     @Override%0A  
@@ -2179,17 +2179,16 @@
  false;%0A
-%0A
         
@@ -2223,25 +2223,24 @@
 ble) o;%0A
-%0A
         
 if (!tab
@@ -2231,21 +2231,38 @@
         
-if (!
+return Objects.equals(
 tableNam
@@ -2262,24 +2262,18 @@
 ableName
-.equals(
+, 
 that.tab
@@ -2283,40 +2283,34 @@
 ame)
-) return false;%0A        if (!key
+ &&%0A                Object
 s.eq
@@ -2310,24 +2310,30 @@
 ects.equals(
+keys, 
 that.keys)) 
@@ -2334,96 +2334,100 @@
 eys)
-) return false;%0A        if (!columns.equals(that.columns)) return false;%0A        return 
+ &&%0A                Objects.equals(columns, that.columns) &&%0A                Objects.equals(
 tabl
@@ -2440,24 +2440,18 @@
 Strategy
-.equals(
+, 
 that.tab
@@ -2468,17 +2468,16 @@
 ategy);%0A
-%0A
     %7D%0A%0A 
@@ -2529,225 +2529,73 @@
     
-int result = tableName.hashCode();%0A        result = 31 * result + keys.hashCode();%0A        result = 31 * result + columns.hashCode();%0A        result = 31 * result + tableShardStrategy.hashCode();%0A        return result
+return Objects.hash(tableName, keys, columns, tableShardStrategy)
 ;%0A  

fix hashcode() bug