Java 类com.google.common.collect.Tables 实例源码

项目:cc-analysis    文件:AnalysisTestHelper.java   
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);
}
项目:gerrit    文件:ChangeNotesParser.java   
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);
}
项目:gerrit    文件:ChangeNotesParser.java   
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);
}
项目:db-table    文件:TableCellMapper.java   
@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)
    );
}
项目:RuneCraftery    文件:GameData.java   
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();
}
项目:RuneCraftery    文件:GameData.java   
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();
}
项目:BetterNutritionMod    文件:GameData.java   
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();
}
项目:LD-FusionTool    文件:LDFusionToolCRUtils.java   
/**
 * 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<>();
                }
            }
    );
}
项目:azure-table    文件:CellSetMutableView.java   
@Override
public Table.Cell<Bytes, Bytes, Bytes> apply(AzureEntity input) {
    return Tables.immutableCell(
            decode(input.getPartitionKey()),
            decode(input.getRowKey()),
            decode(input.getValue()));
}
项目:azure-table    文件:CellSetMutableViewTest.java   
@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)));
}
项目:incubator-provisionr    文件:ImageTable.java   
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());
            }
        });
}
项目:incubator-provisionr    文件:ImageTableTest.java   
@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"));
}
项目:yammer-collections    文件:TransformingTable.java   
@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())
    );
}
项目:yammer-collections    文件:TransformingTable.java   
@Override
public Cell<R, C, V> apply(Cell<R1, C1, V1> input) {
    return Tables.immutableCell(
            fromRowFunction.apply(input.getRowKey()),
            fromColumnFunction.apply(input.getColumnKey()),
            fromValueFunction.apply(input.getValue())
    );
}
项目:yammer-collections    文件:TransformingTableTest.java   
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));
}
项目:ProjectAres    文件:TableView.java   
@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());
        }
    };
}
项目:Blur    文件:BasicMetadataStorage.java   
@Nonnull
@Override
public Table<HOLDER, Class<Object>, Object> getAll() {
    return Tables.unmodifiableTable(metadata);
}
项目:Rapture    文件:ReflexSparseMatrixValue.java   
public ReflexSparseMatrixValue transpose() {
    ReflexSparseMatrixValue ret = new ReflexSparseMatrixValue(2);
    ret.table = Tables.transpose(table);
    return ret;
}
项目:Blur    文件:BasicMetadataStorage.java   
@Nonnull
@Override
public Table<HOLDER, Class<Object>, Object> getAll() {
    return Tables.unmodifiableTable(metadata);
}
项目:owsi-core-parent    文件:Functions2.java   
@Override
public Table<R, C, V> apply(Table<? extends R, ? extends C, ? extends V> input) {
    return input == null ? null : Tables.unmodifiableTable(input);
}
项目:bazel    文件:PhaseVfsStatistics.java   
public PhaseVfsStatistics(ProfilePhase phase) {
  this.phase = phase;
  this.statistics =
      Tables.newCustomTable(
          new EnumMap<ProfilerTask, Map<String, Stat>>(ProfilerTask.class), HashMap::new);
}
项目:jpmml-evaluator    文件:InlineTableUtil.java   
@Override
public Table<Integer, String, String> load(InlineTable inlineTable){
    return Tables.unmodifiableTable(parse(inlineTable));
}
项目:azure-table    文件:RowViewTest.java   
@Test
public void contains_value_returns_false_if_does_not_contain_value_in_row() throws StorageException {
    setAzureTableToContain(Tables.immutableCell(ROW_KEY_1, OTHER_COLUMN_KEY, VALUE_1));

    assertThat(rowView.containsValue(VALUE_1), is(equalTo(false)));
}
项目:azure-table    文件:ColumnViewTest.java   
@Test
public void contains_value_returns_false_if_does_not_contain_value_in_row() throws StorageException {
    setAzureTableToContain(Tables.immutableCell(OTHER_ROW_KEY, COLUMN_KEY_1, VALUE_1));

    assertThat(columnView.containsValue(VALUE_1), is(equalTo(false)));
}
项目:mondo-integration    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of inclusion rules: rows are
 * metamodel URIs, columns are type names or WILDCARD (meaning all types in
 * the metamodel) and cells are either sets of slot names or a singleton set
 * with WILDCARD (meaning "all"). An empty table means "include everything".
 */
public Table<String, String, ImmutableSet<String>> getInclusionRules() {
    return Tables.unmodifiableTable(inclusions);
}
项目:mondo-integration    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of exclusion rules: rows are
 * metamodel URIs, columns are type names and cells are either sets of slot
 * names or a singleton set with WILDCARD (meaning "all"). An empty table
 * means "exclude nothing".
 */
public Table<String, String, ImmutableSet<String>> getExclusionRules() {
    return Tables.unmodifiableTable(exclusions);
}
项目:mondo-hawk    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of inclusion rules: rows are
 * metamodel URIs, columns are type names or WILDCARD (meaning all types in
 * the metamodel) and cells are either sets of slot names or a singleton set
 * with WILDCARD (meaning "all"). An empty table means "include everything".
 */
public Table<String, String, ImmutableSet<String>> getInclusionRules() {
    return Tables.unmodifiableTable(inclusions);
}
项目:mondo-hawk    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of exclusion rules: rows are
 * metamodel URIs, columns are type names and cells are either sets of slot
 * names or a singleton set with WILDCARD (meaning "all"). An empty table
 * means "exclude nothing".
 */
public Table<String, String, ImmutableSet<String>> getExclusionRules() {
    return Tables.unmodifiableTable(exclusions);
}
项目:mondo-collab-framework    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of inclusion rules: rows are
 * metamodel URIs, columns are type names or WILDCARD (meaning all types in
 * the metamodel) and cells are either sets of slot names or a singleton set
 * with WILDCARD (meaning "all"). An empty table means "include everything".
 */
public Table<String, String, ImmutableSet<String>> getInclusionRules() {
    return Tables.unmodifiableTable(inclusions);
}
项目:mondo-collab-framework    文件:EffectiveMetamodelRuleset.java   
/**
 * Returns an unmodifiable view of the table of exclusion rules: rows are
 * metamodel URIs, columns are type names and cells are either sets of slot
 * names or a singleton set with WILDCARD (meaning "all"). An empty table
 * means "exclude nothing".
 */
public Table<String, String, ImmutableSet<String>> getExclusionRules() {
    return Tables.unmodifiableTable(exclusions);
}