Example usage for com.google.common.collect Table containsColumn

List of usage examples for com.google.common.collect Table containsColumn

Introduction

In this page you can find the example usage for com.google.common.collect Table containsColumn.

Prototype

boolean containsColumn(@Nullable Object columnKey);

Source Link

Document

Returns true if the table contains a mapping with the specified column.

Usage

From source file:com.przemo.conjunctions.Joiner.java

/**
 * Builds a joined table, taking the set of rows and array of columns to include
 * @param frows//from  w w  w  . j a v a  2  s.c  o m
 * @param columnJoinName
 * @param cl
 * @param tables
 * @param resultingColumns
 * @return 
 */
protected Table buildJoinedTable(Set<Object> frows, String columnJoinName, Map cl, Table[] tables,
        String[] resultingColumns) {
    Table tr = HashBasedTable.create();
    if (resultingColumns != null) {
        //create the tables based on a resulting rows set
        for (Object r : frows) {
            Table nt = HashBasedTable.create();
            nt.put(r, columnJoinName, cl.get(r));
            int ti = 0;
            for (Table ct : tables) {
                for (String col : resultingColumns) {
                    if (ct.containsColumn(col) && !col.equals(columnJoinName)) {
                        Object v = ct.get(r, col);
                        if (v != null) {
                            if (nt.get(r, col) != null) {
                                col += "_" + ti;
                            }
                            nt.put(r, col, v);
                        }
                    }
                }
                ti++;
            }
            tr.putAll(nt);
        }
    }
    return tr;
}

From source file:com.garethahealy.camelmapstruct.converter.MapStructTypeConverter.java

private String findMethodName(Class<?> from, Class<?> to) throws IllegalAccessException {
    String methodName;//from   ww w  . j  ava 2  s . c o m

    Table<Class<?>, Class<?>, String> resolved = configuration.getResolvedMappingMethods();
    if (resolved.containsRow(from) && resolved.containsColumn(to)) {
        methodName = resolved.get(from, to);
    } else {
        String innerMessage = "Did'nt find method on mapper " + mapper.getClass().getCanonicalName()
                + " that container a parameter of " + from.getCanonicalName() + "; Found possible matches: "
                + StringUtils.join(resolved.values(), ", ");

        LOG.error(innerMessage);

        throw new IllegalAccessException(innerMessage);
    }

    return methodName;
}

From source file:com.przemo.conjunctions.Joiner.java

public Table join(Table[] tables, String columnJoinName, String[] resultingColumns) {
    if (tables != null && columnJoinName != null && tables.length > 0) {
        //tables[0] is the main table against which we're going to check the joining values
        Table main = tables[0];
        Map cl = main.column(columnJoinName);
        Set<Object> frows = cl.keySet();
        if (tables.length > 1 && main.containsColumn(columnJoinName)) {
            if (resultingColumns == null || resultingColumns.length == 0) {
                resultingColumns = concatAllColumns(tables);
            }/*from w  ww.j  av  a 2 s  .  c o m*/
            filterJoinedRows(tables, columnJoinName, frows, cl);
            return buildJoinedTable(frows, columnJoinName, cl, tables, resultingColumns);
        } else {
            return main;
        }
    } else {
        return null;
    }
}