package com.cbooy.cakes.guava.table;

import com.google.common.collect.HashBasedTable;
import org.junit.Test;

/**
 * Created by haoc.
 */
public class HashBasedTableDemo {

    @Test
    public void testCreate() {
        HashBasedTable<String, String, String> table = HashBasedTable.create();

        table.put("cbooy", "vm", "10.94.97.94");
        table.put("cbooy", "name", "haoc");
        table.put("hello", "name", "hi");
        table.put("hello", "vm", "10999");

        System.out.println(table);

        // 遍历
        table.cellSet().forEach(cell -> {
            String columnKey = cell.getColumnKey();
            String rowKey = cell.getRowKey();
            String value = cell.getValue();

            System.out.println(String.format("%s-%s-%s", rowKey, columnKey, value));
        });
    }


}