Example usage for com.google.common.collect MigrateMap makeComputingMap

List of usage examples for com.google.common.collect MigrateMap makeComputingMap

Introduction

In this page you can find the example usage for com.google.common.collect MigrateMap makeComputingMap.

Prototype

@SuppressWarnings("deprecation")
    public static <K, V> ConcurrentMap<K, V> makeComputingMap(Function<? super K, ? extends V> computingFunction) 

Source Link

Usage

From source file:com.alibaba.otter.canal.example.db.dialect.AbstractDbDialect.java

private void initTables(final JdbcTemplate jdbcTemplate) {
    this.tables = MigrateMap.makeComputingMap(new Function<List<String>, Table>() {

        public Table apply(List<String> names) {
            Assert.isTrue(names.size() == 2);
            try {
                Table table = DdlUtils.findTable(jdbcTemplate, names.get(0), names.get(0), names.get(1));
                if (table == null) {
                    throw new NestableRuntimeException(
                            "no found table [" + names.get(0) + "." + names.get(1) + "] , pls check");
                } else {
                    return table;
                }/*from  ww w.ja  v a 2  s  .  com*/
            } catch (Exception e) {
                throw new NestableRuntimeException(
                        "find table [" + names.get(0) + "." + names.get(1) + "] error", e);
            }
        }
    });
}