Java Code Examples for com.google.common.collect.ImmutableTable#copyOf()

The following examples show how to use com.google.common.collect.ImmutableTable#copyOf() . 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: ImmutableCollectionSerializers.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: CashFlowReport.java    From Strata with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: ConfigurableFeatureManager.java    From OpenModsLib with MIT License 6 votes vote down vote up
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);
}
 
Example 4
Source File: AnnotationUtils.java    From Alink with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: TradeReport.java    From Strata with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: ManualLexicon.java    From EasySRL with Apache License 2.0 4 votes vote down vote up
public ManualLexicon(final File lexiconFile) throws IOException {
	this(ImmutableTable.copyOf(loadLexicon(lexiconFile)));
}
 
Example 7
Source File: BDDReachabilityAnalysis.java    From batfish with Apache License 2.0 4 votes vote down vote up
public Table<StateExpr, StateExpr, Transition> getForwardEdgeTable() {
  return ImmutableTable.copyOf(_forwardEdgeTable);
}
 
Example 8
Source File: StatementSupportBundle.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
@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));
}
 
Example 9
Source File: TableEncoding.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Encoding.Of
static <R, C, V> ImmutableTable<R, C, V> init(Table<? extends R, ? extends C, ? extends V> table) {
  return ImmutableTable.copyOf(table);
}
 
Example 10
Source File: BDDReachabilityUtils.java    From batfish with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}