com.google.common.collect.ImmutableTable#copyOf ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableTable#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public static void register(final Kryo kryo) {
  // register list
  final ImmutableListSerializer serializer = new ImmutableListSerializer();
  kryo.register(ImmutableList.class, serializer);
  kryo.register(ImmutableList.of().getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1)).getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)).subList(1, 2).getClass(), serializer);
  kryo.register(ImmutableList.of().reverse().getClass(), serializer);
  kryo.register(Lists.charactersOf("dremio").getClass(), serializer);

  final HashBasedTable baseTable = HashBasedTable.create();
  baseTable.put(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
  baseTable.put(Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6));
  ImmutableTable table = ImmutableTable.copyOf(baseTable);
  kryo.register(table.values().getClass(), serializer);
}
 
源代码2 项目: Strata   文件: CashFlowReport.java
private CashFlowReport(
    LocalDate valuationDate,
    Instant runInstant,
    List<ExplainKey<?>> columnKeys,
    List<String> columnHeaders,
    Table<Integer, Integer, Object> data) {
  JodaBeanUtils.notNull(valuationDate, "valuationDate");
  JodaBeanUtils.notNull(runInstant, "runInstant");
  JodaBeanUtils.notNull(columnKeys, "columnKeys");
  JodaBeanUtils.notNull(columnHeaders, "columnHeaders");
  JodaBeanUtils.notNull(data, "data");
  this.valuationDate = valuationDate;
  this.runInstant = runInstant;
  this.columnKeys = ImmutableList.copyOf(columnKeys);
  this.columnHeaders = ImmutableList.copyOf(columnHeaders);
  this.data = ImmutableTable.copyOf(data);
}
 
源代码3 项目: OpenModsLib   文件: ConfigurableFeatureManager.java
public Table<String, String, Property> loadFromConfiguration(Configuration config) {
	final Table<String, String, Property> properties = HashBasedTable.create();
	for (Table.Cell<String, String, FeatureEntry> cell : features.cellSet()) {
		final FeatureEntry entry = cell.getValue();
		if (!entry.isConfigurable) continue;

		final String categoryName = cell.getRowKey();
		final String featureName = cell.getColumnKey();
		final Property prop = config.get(categoryName, featureName, entry.isEnabled);
		properties.put(categoryName, featureName, prop);
		if (!prop.wasRead()) continue;

		if (!prop.isBooleanValue()) prop.set(entry.isEnabled);
		else entry.isEnabled = prop.getBoolean(entry.isEnabled);
	}

	return ImmutableTable.copyOf(properties);
}
 
源代码4 项目: Alink   文件: AnnotationUtils.java
@SuppressWarnings("unchecked")
private static Table<String, IOType, Wrapper<AlgoOperator>> loadIoOpClasses() {
    Reflections reflections = new Reflections("com.alibaba.alink");
    Table<String, IOType, Wrapper<AlgoOperator>> table = HashBasedTable.create();
    for (Class<?> clazz : reflections.getTypesAnnotatedWith(IoOpAnnotation.class)) {
        if (!AlgoOperator.class.isAssignableFrom(clazz)) {
            LOG.error("Class annotated with @IoOpAnnotation should be subclass of AlgoOperator: {}",
                    clazz.getCanonicalName());
            continue;
        }

        IoOpAnnotation annotation = clazz.getAnnotation(IoOpAnnotation.class);
        String name = annotation.name();
        IOType ioType = annotation.ioType();
        boolean hasTimestamp = annotation.hasTimestamp();

        Wrapper<AlgoOperator> origin = table.put(name, ioType,
                new Wrapper<>((Class<? extends AlgoOperator>) clazz, hasTimestamp));


        if (origin != null) {
            LOG.error("Multiple IO Operator class with same name {} and IOType: {}: {} and {}",
                    name, ioType, origin.clazz.getCanonicalName(), clazz.getCanonicalName());
        }
    }

    return ImmutableTable.copyOf(table);
}
 
源代码5 项目: Strata   文件: TradeReport.java
private TradeReport(
    LocalDate valuationDate,
    Instant runInstant,
    List<TradeReportColumn> columns,
    Table<Integer, Integer, Result<?>> data) {
  JodaBeanUtils.notNull(valuationDate, "valuationDate");
  JodaBeanUtils.notNull(runInstant, "runInstant");
  JodaBeanUtils.notNull(columns, "columns");
  JodaBeanUtils.notNull(data, "data");
  this.valuationDate = valuationDate;
  this.runInstant = runInstant;
  this.columns = ImmutableList.copyOf(columns);
  this.data = ImmutableTable.copyOf(data);
}
 
源代码6 项目: EasySRL   文件: ManualLexicon.java
public ManualLexicon(final File lexiconFile) throws IOException {
	this(ImmutableTable.copyOf(loadLexicon(lexiconFile)));
}
 
源代码7 项目: batfish   文件: BDDReachabilityAnalysis.java
public Table<StateExpr, StateExpr, Transition> getForwardEdgeTable() {
  return ImmutableTable.copyOf(_forwardEdgeTable);
}
 
源代码8 项目: yangtools   文件: StatementSupportBundle.java
@Override
public StatementSupportBundle build() {
    Preconditions.checkState(parent != null, "Parent must not be null");
    return new StatementSupportBundle(parent, supportedVersions, ImmutableMap.copyOf(commonStatements),
            ImmutableMap.copyOf(namespaces), ImmutableTable.copyOf(versionSpecificStatements));
}
 
源代码9 项目: immutables   文件: TableEncoding.java
@Encoding.Of
static <R, C, V> ImmutableTable<R, C, V> init(Table<? extends R, ? extends C, ? extends V> table) {
  return ImmutableTable.copyOf(table);
}
 
源代码10 项目: batfish   文件: BDDReachabilityUtils.java
/**
 * Returns an immutable copy of the input table that has been materialized in transposed form.
 *
 * <p>Use this instead of {@link Tables#transpose(Table)} if the result will be iterated on in
 * row-major order. Transposing the table alone does not change the row-major vs column-major
 * internal representation so the performance of row-oriented operations is abysmal. Instead, we
 * need to actually materialize the transposed representation.
 */
public static <R, C, V> Table<C, R, V> transposeAndMaterialize(Table<R, C, V> edgeTable) {
  return ImmutableTable.copyOf(Tables.transpose(edgeTable));
}