當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableTable.builder方法代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableTable.builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableTable.builder方法的具體用法?Java ImmutableTable.builder怎麽用?Java ImmutableTable.builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.ImmutableTable的用法示例。


在下文中一共展示了ImmutableTable.builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MediaTypeClassifierImpl

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
MediaTypeClassifierImpl(Iterable<? extends MediaType> mts) {
  Table<String, String, Set<MediaType>> typeTable =
      HashBasedTable.<String, String, Set<MediaType>>create();
  for (MediaType mt : mts) {
    String type = mt.type();
    String subtype = mt.subtype();
    Set<MediaType> typeSet = typeTable.get(type, subtype);
    if (typeSet == null) {
      typeSet = Sets.newLinkedHashSet();
      typeTable.put(type, subtype, typeSet);
    }
    typeSet.add(mt);
  }

  ImmutableTable.Builder<String, String, ImmutableSet<MediaType>> b =
      ImmutableTable.builder();
  for (Table.Cell<String, String, Set<MediaType>> cell
       : typeTable.cellSet()) {
    b.put(cell.getRowKey(), cell.getColumnKey(), ImmutableSet.copyOf(cell.getValue()));
  }
  this.types = b.build();
}
 
開發者ID:OWASP,項目名稱:url-classifier,代碼行數:23,代碼來源:MediaTypeClassifierBuilder.java

示例2: parseReviewerFieldValues

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public static ReviewerSet parseReviewerFieldValues(Iterable<String> values) {
  ImmutableTable.Builder<ReviewerStateInternal, Account.Id, Timestamp> b =
      ImmutableTable.builder();
  for (String v : values) {
    int f = v.indexOf(',');
    if (f < 0) {
      continue;
    }
    int l = v.lastIndexOf(',');
    if (l == f) {
      continue;
    }
    b.put(
        ReviewerStateInternal.valueOf(v.substring(0, f)),
        Account.Id.parse(v.substring(f + 1, l)),
        new Timestamp(Long.valueOf(v.substring(l + 1, v.length()))));
  }
  return ReviewerSet.fromTable(b.build());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:20,代碼來源:ChangeField.java

示例3: parseReviewerByEmailFieldValues

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public static ReviewerByEmailSet parseReviewerByEmailFieldValues(Iterable<String> values) {
  ImmutableTable.Builder<ReviewerStateInternal, Address, Timestamp> b = ImmutableTable.builder();
  for (String v : values) {
    int f = v.indexOf(',');
    if (f < 0) {
      continue;
    }
    int l = v.lastIndexOf(',');
    if (l == f) {
      continue;
    }
    b.put(
        ReviewerStateInternal.valueOf(v.substring(0, f)),
        Address.parse(v.substring(f + 1, l)),
        new Timestamp(Long.valueOf(v.substring(l + 1, v.length()))));
  }
  return ReviewerByEmailSet.fromTable(b.build());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:19,代碼來源:ChangeField.java

示例4: filteredCopy

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
/**
 * Return a new {@code ProvenancedConfusionMatrix} containing only those provenance entries
 * matching the provided predicate.
 */
public ProvenancedConfusionMatrix<CellFiller> filteredCopy(Predicate<CellFiller> predicate) {
  final ImmutableTable.Builder<Symbol, Symbol, List<CellFiller>> newTable =
      ImmutableTable.builder();

  for (final Cell<Symbol, Symbol, List<CellFiller>> curCell : table.cellSet()) {
    final List<CellFiller> newFiller = FluentIterable.from(curCell.getValue())
        .filter(predicate).toList();
    if (!newFiller.isEmpty()) {
      newTable.put(curCell.getRowKey(), curCell.getColumnKey(), newFiller);
    }

  }

  return new ProvenancedConfusionMatrix<CellFiller>(newTable.build());
}
 
開發者ID:BBN-E,項目名稱:bue-common-open,代碼行數:20,代碼來源:ProvenancedConfusionMatrix.java

示例5: build

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public ImmutableSetMultitable<R, C, V> build() {
  final ImmutableTable.Builder<R, C, Collection<V>> immutableTable =
      ImmutableTable.builder();

  int size = 0;
  ImmutableSet.Builder<R> rowIterationBuilder = ImmutableSet.builder();
  ImmutableSet.Builder<C> columnIterationBuilder = ImmutableSet.builder();

  for (final RowKeyColumnKeyPair<R, C> rowKeyColKey : rowInsertionOrder.build()) {
    final ImmutableSet<V> valuesForPair =
        tableWeCanLookUpIn.get(rowKeyColKey.row(), rowKeyColKey.column()).build();
    size += valuesForPair.size();
    immutableTable.put(rowKeyColKey.row(), rowKeyColKey.column(),
        valuesForPair);
    rowIterationBuilder.add(rowKeyColKey.row());
    columnIterationBuilder.add(rowKeyColKey.column());
  }

  return new ImmutableSetMultitable<>(immutableTable.build(), size, rowIterationBuilder.build(),
      columnIterationBuilder.build());
}
 
開發者ID:BBN-E,項目名稱:bue-common-open,代碼行數:22,代碼來源:ImmutableSetMultitable.java

示例6: build

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public ImmutableListMultitable<R, C, V> build() {
  final ImmutableTable.Builder<R, C, Collection<V>> immutableTable =
      ImmutableTable.builder();

  int size = 0;
  ImmutableSet.Builder<R> rowIterationBuilder = ImmutableSet.builder();
  ImmutableSet.Builder<C> columnIterationBuilder = ImmutableSet.builder();

  for (final RowKeyColumnKeyPair<R, C> rowKeyColKey : rowInsertionOrder.build()) {
    final ImmutableList<V> valuesForPair =
        tableWeCanLookUpIn.get(rowKeyColKey.row(), rowKeyColKey.column()).build();
    size += valuesForPair.size();
    immutableTable.put(rowKeyColKey.row(), rowKeyColKey.column(),
        valuesForPair);
    rowIterationBuilder.add(rowKeyColKey.row());
    columnIterationBuilder.add(rowKeyColKey.column());
  }

  return new ImmutableListMultitable<>(immutableTable.build(), size,
      rowIterationBuilder.build(),
      columnIterationBuilder.build());
}
 
開發者ID:BBN-E,項目名稱:bue-common-open,代碼行數:23,代碼來源:ImmutableListMultitable.java

示例7: loadSymbolTable

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public static ImmutableTable<Symbol, Symbol, Symbol> loadSymbolTable(CharSource input)
    throws IOException {
  final ImmutableTable.Builder<Symbol, Symbol, Symbol> ret = ImmutableTable.builder();

  int lineNo = 0;
  for (final String line : input.readLines()) {
    final List<String> parts = StringUtils.onTabs().splitToList(line);
    if (parts.size() != 3) {
      throw new IOException(String.format("Invalid line %d when reading symbol table: %s",
          lineNo, line));
    }
    ret.put(Symbol.from(parts.get(0)), Symbol.from(parts.get(1)), Symbol.from(parts.get(2)));
    ++lineNo;
  }

  return ret.build();
}
 
開發者ID:BBN-E,項目名稱:bue-common-open,代碼行數:18,代碼來源:FileUtils.java

示例8: getPrecedenceVariableValues

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
private ImmutableTable<V, V, Double> getPrecedenceVariableValues(
    VariableSet.VariableExtractor variableExtractor) {
  ImmutableTable.Builder<V, V, Double> ans = ImmutableTable.builder();
  List<Cell<V, V, IloNumVar>> varsAsList = Lists
      .newArrayList(this.precedenceVariables.cellSet());
  IloNumVar[] varArray = new IloNumVar[varsAsList.size()];
  int i = 0;
  for (Cell<V, V, IloNumVar> cell : varsAsList) {
    varArray[i++] = cell.getValue();
  }
  double[] varVals;
  try {
    varVals = variableExtractor.getValuesVE(varArray);
  } catch (IloException e) {
    throw new RuntimeException(e);
  }
  for (int j = 0; j < varsAsList.size(); j++) {
    ans.put(varsAsList.get(j).getRowKey(), varsAsList.get(j).getColumnKey(),
        varVals[j]);
  }
  return ans.build();
}
 
開發者ID:rma350,項目名稱:kidneyExchange,代碼行數:23,代碼來源:MinWaitingTimeKepSolver.java

示例9: DelTemplateSelector

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
private DelTemplateSelector(Builder<T> builder) {
  ImmutableTable.Builder<String, String, Group<T>> nameAndVariantBuilder =
      ImmutableTable.builder();
  ImmutableListMultimap.Builder<String, T> delTemplateNameToValuesBuilder =
      ImmutableListMultimap.builder();
  for (Table.Cell<String, String, Group.Builder<T>> entry :
      builder.nameAndVariantToGroup.cellSet()) {
    Group<T> group = entry.getValue().build();
    nameAndVariantBuilder.put(entry.getRowKey(), entry.getColumnKey(), group);
    String delTemplateName = entry.getRowKey();
    if (group.defaultValue != null) {
      delTemplateNameToValuesBuilder.put(delTemplateName, group.defaultValue);
    }
    delTemplateNameToValuesBuilder.putAll(delTemplateName, group.delpackageToValue.values());
  }
  this.nameAndVariantToGroup = nameAndVariantBuilder.build();
  this.delTemplateNameToValues = delTemplateNameToValuesBuilder.build();
}
 
開發者ID:google,項目名稱:closure-templates,代碼行數:19,代碼來源:DelTemplateSelector.java

示例10: CompareView

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public CompareView(List<KnownColormap> colorMaps)
{
	setLayout(new GridLayout(1, 0));

	List<ColormapQuality> metrics = getMetrics();

	ImmutableTable.Builder<KnownColormap, ColormapQuality, Double> builder = ImmutableTable.builder();

	for (KnownColormap cm : colorMaps)
	{
		for (ColormapQuality metric : metrics)
		{
			builder.put(cm, metric, metric.getQuality(cm));
		}
	}

	Table<KnownColormap, ColormapQuality, Double> infoTable = builder.build();

	add(new CompareViewPanel(infoTable));
	add(new CompareViewPanel(infoTable));
	add(new CompareViewPanel(infoTable));
}
 
開發者ID:igd-iva,項目名稱:colormap-explorer,代碼行數:23,代碼來源:CompareView.java

示例11: fromCsvResource

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
/**
 * Load the list of AMIs from a resource file (csv format)
 * <p/>
 * Note: the parser is doing only split by comma. There is no
 * support for escaping line components
 *
 * @param resource path to resource
 * @return an instance of {@see ImageTable}
 * @throws IOException
 */
public static ImageTable fromCsvResource(String resource) throws IOException {
    checkNotNull(resource, "resource is null");

    List<String> lines = Resources.readLines(Resources.getResource(ImageTable.class, resource), Charsets.UTF_8);
    checkArgument(!lines.isEmpty(), "the resource is an empty file");

    final ImmutableTable.Builder<String, String, String> table = ImmutableTable.builder();
    final Iterable<String> headers = extractHeaders(lines);

    int index = 0;
    for (String line : Iterables.skip(lines, 1)) {
        final Iterable<Table.Cell<String, String, String>> cells =
            combineHeadersWithLinePartsAsTableCells(index, headers, COMMA.split(line));
        for (Table.Cell<String, String, String> cell : cells) {
            table.put(cell);
        }
        index++;
    }

    return new ImageTable(table.build());
}
 
開發者ID:apache,項目名稱:incubator-provisionr,代碼行數:32,代碼來源:ImageTable.java

示例12: deserialize

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
@Override
public ImmutableTable<?, ?, ?> deserialize(final JsonParser jp, final DeserializationContext ctxt)
    throws IOException {
  final ImmutableTable.Builder<Object, Object, Object> tableBuilder = ImmutableTable.builder();

  final JavaType rowKeyType = javaType.containedTypeOrUnknown(0);
  final JavaType columnKeyType = javaType.containedTypeOrUnknown(1);
  final JavaType valueType = javaType.containedTypeOrUnknown(2);
  final JavaType mapifiedType =
      ctxt.getTypeFactory()
          .constructMapType(
              Map.class,
              rowKeyType,
              ctxt.getTypeFactory().constructMapType(Map.class, columnKeyType, valueType));

  final Map<Object, Map<Object, Object>> rowMap = ctxt.readValue(jp, mapifiedType);

  for (final Map.Entry<Object, Map<Object, Object>> rowEntry : rowMap.entrySet()) {
    final Object rowKey = rowEntry.getKey();
    for (final Map.Entry<Object, Object> cellEntry : rowEntry.getValue().entrySet()) {
      final Object colKey = cellEntry.getKey();
      final Object val = cellEntry.getValue();
      tableBuilder.put(rowKey, colKey, val);
    }
  }
  return tableBuilder.build();
}
 
開發者ID:spotify,項目名稱:bazel-tools,代碼行數:28,代碼來源:TableDeserializer.java

示例13: setAnimation

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public void setAnimation(Triple<Integer, Integer, Float> animData, Table<Integer, Optional<Node<?>>, Key> keyData)
{
    ImmutableTable.Builder<Integer, Node<?>, Key> builder = ImmutableTable.builder();
    for(Table.Cell<Integer, Optional<Node<?>>, Key> key : keyData.cellSet())
    {
        builder.put(key.getRowKey(), key.getColumnKey().or(this), key.getValue());
    }
    setAnimation(new Animation(animData.getLeft(), animData.getMiddle(), animData.getRight(), builder.build()));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:10,代碼來源:B3DModel.java

示例14: ofMapWithColumn

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public static <R, C, V> ImmutableTable<R, C, V> ofMapWithColumn(Map<R, V> map, C column) {
    checkNotNull(map, "Null map");
    checkNotNull(column, "Null column");
    ImmutableTable.Builder<R, C, V> tableBuilder = ImmutableTable.builder();
    map.forEach((key, value) -> tableBuilder.put(key, column, value));
    return tableBuilder.build();
}
 
開發者ID:SpudCompat,項目名稱:SpudCompat,代碼行數:8,代碼來源:ImmutableTables.java

示例15: build

import com.google.common.collect.ImmutableTable; //導入方法依賴的package包/類
public DeadCodeMap build() {
  ImmutableTable.Builder<String, String, ImmutableSet<String>> deadMethodsBuilder =
      ImmutableTable.builder();
  for (Table.Cell<String, String, Set<String>> cell : this.deadMethods.cellSet()) {
    deadMethodsBuilder.put(
        cell.getRowKey(),
        cell.getColumnKey(),
        ImmutableSet.copyOf(cell.getValue()));
  }
  return new DeadCodeMap(
      ImmutableSet.copyOf(deadClasses),
      deadMethodsBuilder.build(),
      ImmutableMultimap.copyOf(deadFields));
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:15,代碼來源:DeadCodeMap.java


注:本文中的com.google.common.collect.ImmutableTable.builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。