当前位置: 首页>>代码示例>>Java>>正文


Java Tables类代码示例

本文整理汇总了Java中com.google.common.collect.Tables的典型用法代码示例。如果您正苦于以下问题:Java Tables类的具体用法?Java Tables怎么用?Java Tables使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tables类属于com.google.common.collect包,在下文中一共展示了Tables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printResultOfTokenStream

import com.google.common.collect.Tables; //导入依赖的package包/类
public static void printResultOfTokenStream(PrintStream out, TokenStream ts) throws IOException {
	CharTermAttribute termAttr = ts.getAttribute(CharTermAttribute.class);
	TypeAttribute typeAttr = ts.getAttribute(TypeAttribute.class);
	OffsetAttribute offAttr = ts.getAttribute(OffsetAttribute.class);
	PositionIncrementAttribute posIncAttr = ts.getAttribute(PositionIncrementAttribute.class);
	PositionLengthAttribute posLenAttr = ts.getAttribute(PositionLengthAttribute.class);
	ts.reset();
	Table<String, String, String> contentTable = Tables.newCustomTable(new LinkedHashMap<String, Map<String, String>>(),
			new Supplier<Map<String, String>>() {
				@Override
				public Map<String, String> get() {
					return Maps.newLinkedHashMap();
				}
			});
	int lineNo = 1;
	int pos = 0;
	while (ts.incrementToken()) {
		String lineId = lineNo + ".";
		contentTable.put(lineId, "term", termAttr.toString());
		contentTable.put(lineId, "type", typeAttr.type());
		contentTable.put(lineId, "startOffset", offAttr.startOffset() + "");
		contentTable.put(lineId, "endOffset", offAttr.endOffset() + "");
		contentTable.put(lineId, "posInc", posIncAttr.getPositionIncrement() + "");
		contentTable.put(lineId, "posLen", posLenAttr.getPositionLength() + "");
		pos += posIncAttr.getPositionIncrement();
		contentTable.put(lineId, "pos", pos + "");

		lineNo++;
	}
	printTable(out, contentTable);
}
 
开发者ID:thihy,项目名称:cc-analysis,代码行数:32,代码来源:AnalysisTestHelper.java

示例2: buildState

import com.google.common.collect.Tables; //导入依赖的package包/类
private ChangeNotesState buildState() {
  return ChangeNotesState.create(
      tip.copy(),
      id,
      new Change.Key(changeId),
      createdOn,
      lastUpdatedOn,
      ownerId,
      branch,
      buildCurrentPatchSetId(),
      subject,
      topic,
      originalSubject,
      submissionId,
      assignee != null ? assignee.orElse(null) : null,
      status,
      Sets.newLinkedHashSet(Lists.reverse(pastAssignees)),
      hashtags,
      patchSets,
      buildApprovals(),
      ReviewerSet.fromTable(Tables.transpose(reviewers)),
      ReviewerByEmailSet.fromTable(Tables.transpose(reviewersByEmail)),
      pendingReviewers,
      pendingReviewersByEmail,
      allPastReviewers,
      buildReviewerUpdates(),
      submitRecords,
      buildAllMessages(),
      buildMessagesByPatchSet(),
      comments,
      readOnlyUntil,
      isPrivate,
      workInProgress,
      hasReviewStarted,
      revertOf);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:ChangeNotesParser.java

示例3: parseWorkInProgress

import com.google.common.collect.Tables; //导入依赖的package包/类
private void parseWorkInProgress(ChangeNotesCommit commit) throws ConfigInvalidException {
  String raw = parseOneFooter(commit, FOOTER_WORK_IN_PROGRESS);
  if (raw == null) {
    // No change to WIP state in this revision.
    previousWorkInProgressFooter = null;
    return;
  } else if (Boolean.TRUE.toString().equalsIgnoreCase(raw)) {
    // This revision moves the change into WIP.
    previousWorkInProgressFooter = true;
    if (workInProgress == null) {
      // Because this is the first time workInProgress is being set, we know
      // that this change's current state is WIP. All the reviewer updates
      // we've seen so far are pending, so take a snapshot of the reviewers
      // and reviewersByEmail tables.
      pendingReviewers =
          ReviewerSet.fromTable(Tables.transpose(ImmutableTable.copyOf(reviewers)));
      pendingReviewersByEmail =
          ReviewerByEmailSet.fromTable(Tables.transpose(ImmutableTable.copyOf(reviewersByEmail)));
      workInProgress = true;
    }
    return;
  } else if (Boolean.FALSE.toString().equalsIgnoreCase(raw)) {
    previousWorkInProgressFooter = false;
    hasReviewStarted = true;
    if (workInProgress == null) {
      workInProgress = false;
    }
    return;
  }
  throw invalidFooter(FOOTER_WORK_IN_PROGRESS, raw);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ChangeNotesParser.java

示例4: map

import com.google.common.collect.Tables; //导入依赖的package包/类
@Override
public Table.Cell<R, C, V> map(int index, ResultSet r, StatementContext ctx) throws SQLException {
    return Tables.immutableCell(
            rowMapper.map(index, r, ctx),
            columnMapper.map(index, r, ctx),
            valueMapper.map(index, r, ctx)
    );
}
 
开发者ID:reines,项目名称:db-table,代码行数:9,代码来源:TableCellMapper.java

示例5: buildModObjectTable

import com.google.common.collect.Tables; //导入依赖的package包/类
public static void buildModObjectTable()
{
    if (modObjectTable != null)
    {
        throw new IllegalStateException("Illegal call to buildModObjectTable!");
    }

    Map<Integer, Cell<String, String, Integer>> map = Maps.transformValues(idMap, new Function<ItemData,Cell<String,String,Integer>>() {
        public Cell<String,String,Integer> apply(ItemData data)
        {
            if ("Minecraft".equals(data.getModId()) || !data.isOveridden())
            {
                return null;
            }
            return Tables.immutableCell(data.getModId(), data.getItemType(), data.getItemId());
        }
    });

    Builder<String, String, Integer> tBuilder = ImmutableTable.builder();
    for (Cell<String, String, Integer> c : map.values())
    {
        if (c!=null)
        {
            tBuilder.put(c);
        }
    }
    modObjectTable = tBuilder.build();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:29,代码来源:GameData.java

示例6: newHashTable

import com.google.common.collect.Tables; //导入依赖的package包/类
/**
 * Creates a new HashMap backed {@link Table}.
 */
public static <R, C, V> Table<R, C, V> newHashTable() {
    return Tables.newCustomTable(
            new HashMap<R, Map<C, V>>(),
            new Supplier<Map<C, V>>() {
                @Override
                public Map<C, V> get() {
                    return new HashMap<>();
                }
            }
    );
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:15,代码来源:LDFusionToolCRUtils.java

示例7: apply

import com.google.common.collect.Tables; //导入依赖的package包/类
@Override
public Table.Cell<Bytes, Bytes, Bytes> apply(AzureEntity input) {
    return Tables.immutableCell(
            decode(input.getPartitionKey()),
            decode(input.getRowKey()),
            decode(input.getValue()));
}
 
开发者ID:yammer,项目名称:azure-table,代码行数:8,代码来源:CellSetMutableView.java

示例8: contains_delegates_to_table

import com.google.common.collect.Tables; //导入依赖的package包/类
@Test
public void contains_delegates_to_table() {
    Object o1 = new Object();
    Object o2 = new Object();
    Table.Cell<Object, Object, Object> cell = Tables.immutableCell(o1, o2, new Object());
    when(baseAzureTable.contains(o1, o2)).thenReturn(true);

    assertThat(set.contains(cell), is(equalTo(true)));
}
 
开发者ID:yammer,项目名称:azure-table,代码行数:10,代码来源:CellSetMutableViewTest.java

示例9: combineHeadersWithLinePartsAsTableCells

import com.google.common.collect.Tables; //导入依赖的package包/类
static Iterable<Table.Cell<String, String, String>> combineHeadersWithLinePartsAsTableCells(
    int index, Iterable<String> headers, Iterable<String> lineParts
) {
    final String rowKey = "" + index;
    return transform(zip(headers, lineParts),
        new Function<Map.Entry<String, String>, Table.Cell<String, String, String>>() {
            @Override
            public Table.Cell<String, String, String> apply(Map.Entry<String, String> entry) {
                checkNotNull(entry, "entry is null");
                return Tables.immutableCell(rowKey, entry.getKey(), entry.getValue());
            }
        });
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:14,代码来源:ImageTable.java

示例10: testCombineHeadersWithLinePartsAsTableCells

import com.google.common.collect.Tables; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCombineHeadersWithLinePartsAsTableCells() {
    final ImmutableList<String> headers = ImmutableList.of("a", "b");
    final ImmutableList<String> lineParts = ImmutableList.of("1", "2");

    Iterable<Table.Cell<String, String, String>> cells =
        ImageTable.combineHeadersWithLinePartsAsTableCells(0, headers, lineParts);

    assertThat(cells).contains(Tables.immutableCell("0", "a", "1"));
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:12,代码来源:ImageTableTest.java

示例11: apply

import com.google.common.collect.Tables; //导入依赖的package包/类
@Override
public Cell<R1, C1, V1> apply(Cell<R, C, V> input) {
    return Tables.immutableCell(
            toRowFunction.apply(input.getRowKey()),
            toColumnFunction.apply(input.getColumnKey()),
            toValueFunction.apply(input.getValue())
    );
}
 
开发者ID:yammer,项目名称:yammer-collections,代码行数:9,代码来源:TransformingTable.java

示例12: cellSet_delegates_to_backing_table

import com.google.common.collect.Tables; //导入依赖的package包/类
public void cellSet_delegates_to_backing_table() {
    Set<Table.Cell<String, String, String>> cellSet = Collections.singleton(Tables.immutableCell(STRING_ROW_KEY_1, STRING_COLUMN_KEY_1, STRING_VALUE_1));
    when(backingTableMock.cellSet()).thenReturn(cellSet);

    Table.Cell<Float, Long, Integer> expectedCell = Tables.immutableCell(ROW_KEY_1, COLUMN_KEY_1, VALUE_1);

    //noinspection unchecked
    assertThat(transformingTable.cellSet(), containsInAnyOrder(expectedCell));
}
 
开发者ID:yammer,项目名称:yammer-collections,代码行数:10,代码来源:TransformingTableTest.java

示例13: cellSet

import com.google.common.collect.Tables; //导入依赖的package包/类
@Override
public Set<Cell<R, C, V>> cellSet() {
    return new AbstractSet<Cell<R, C, V>>() {
        @Override
        public int size() {
            return TableView.this.size();
        }

        @Override
        public boolean isEmpty() {
            return TableView.this.isEmpty();
        }

        @Override
        public boolean contains(Object o) {
            if(!(o instanceof Cell)) return false;
            final Cell cell = (Cell) o;
            return Objects.equals(get(cell.getRowKey(), cell.getColumnKey()), cell.getValue());
        }

        @Override
        public Stream<Cell<R, C, V>> stream() {
            return map.entrySet()
                      .stream()
                      .flatMap(row -> row.getValue()
                                         .entrySet()
                                         .stream()
                                         .map(col -> Tables.immutableCell(row.getKey(),
                                                                          col.getKey(),
                                                                          col.getValue())));
        }

        @Override
        public Spliterator<Cell<R, C, V>> spliterator() {
            return stream().spliterator();
        }

        @Override
        public Iterator<Cell<R, C, V>> iterator() {
            return Spliterators.iterator(spliterator());
        }
    };
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:44,代码来源:TableView.java

示例14: getAll

import com.google.common.collect.Tables; //导入依赖的package包/类
@Nonnull
@Override
public Table<HOLDER, Class<Object>, Object> getAll() {
    return Tables.unmodifiableTable(metadata);
}
 
开发者ID:BlurEngine,项目名称:Blur,代码行数:6,代码来源:BasicMetadataStorage.java

示例15: transpose

import com.google.common.collect.Tables; //导入依赖的package包/类
public ReflexSparseMatrixValue transpose() {
    ReflexSparseMatrixValue ret = new ReflexSparseMatrixValue(2);
    ret.table = Tables.transpose(table);
    return ret;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:6,代码来源:ReflexSparseMatrixValue.java


注:本文中的com.google.common.collect.Tables类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。