Java Code Examples for com.google.common.collect.Table#size()

The following examples show how to use com.google.common.collect.Table#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapConfig.java    From qconfig with MIT License 6 votes vote down vote up
private static Map<String, String> parseTable(String data, boolean trimValue) throws IOException {
    if (data == null) {
        return ImmutableMap.of();
    }

    TableConfig.TableParser parser;
    if (trimValue) {
        parser = TableConfig.TRIM_PARSER;
    } else {
        parser = TableConfig.NOT_TRIM_PARSER;
    }

    Table<String, String, String> table = parser.parse(data);
    Map<String, String> map = new LinkedHashMap<String, String>(table.size());
    for (Table.Cell<String, String, String> cell : table.cellSet()) {
        map.put(generateKey(cell.getRowKey(), cell.getColumnKey()), cell.getValue());
    }
    return ImmutableMap.copyOf(map);
}
 
Example 2
Source File: SubscriberStatusChecker.java    From qmq with Apache License 2.0 6 votes vote down vote up
private void cleanPullLogAndCheckpoint() {
    final Table<String, String, PullLog> pullLogs = storage.allPullLogs();
    if (pullLogs == null || pullLogs.size() == 0) return;

    // delete all pull log without max pulled message sequence
    for (final String groupAndSubject : pullLogs.columnKeySet()) {
        final GroupAndSubject gs = GroupAndSubject.parse(groupAndSubject);
        final long maxPulledMessageSequence = storage.getMaxPulledMessageSequence(gs.getSubject(), gs.getGroup());
        if (maxPulledMessageSequence == -1) {
            for (final Map.Entry<String, PullLog> entry : pullLogs.column(groupAndSubject).entrySet()) {
                final String consumerId = entry.getKey();
                LOG.info("remove pull log. subject: {}, group: {}, consumerId: {}", gs.getSubject(), gs.getGroup(), consumerId);
                storage.destroyPullLog(gs.getSubject(), gs.getGroup(), consumerId);
            }
        }
    }
}
 
Example 3
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Point create() {
    Composite parent = getParent();
    Table<ToolTipString, ToolTipString, ToolTipString> model = getModel();
    if (parent == null || model.size() == 0) {
        // avoid displaying empty tool tips.
        return null;
    }
    setupControl(parent);
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    setupControl(scrolledComposite);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    fComposite = composite;
    composite.setLayout(new GridLayout(3, false));
    setupControl(composite);
    Set<ToolTipString> rowKeySet = model.rowKeySet();
    for (ToolTipString row : rowKeySet) {
        Set<Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet();
        for (Entry<ToolTipString, ToolTipString> entry : entrySet) {
            Label nameLabel = new Label(composite, SWT.NO_FOCUS);
            nameLabel.setText(entry.getKey().toString());
            setupControl(nameLabel);
            Label separator = new Label(composite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL);
            GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
            gd.heightHint = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            separator.setLayoutData(gd);
            setupControl(separator);
            Label valueLabel = new Label(composite, SWT.NO_FOCUS);
            valueLabel.setText(entry.getValue().toString());
            setupControl(valueLabel);
        }
    }
    scrolledComposite.setContent(composite);
    Point preferredSize = computePreferredSize();
    scrolledComposite.setMinSize(preferredSize.x, preferredSize.y);
    return preferredSize;
}
 
Example 4
Source File: TableSerializer.java    From jackson-datatypes-collections with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasSingleElement(final Table<?, ?, ?> table) {
    return table.size() == 1;
}