下面列出了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);
}
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);
}
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);
}
@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);
}
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);
}
public ManualLexicon(final File lexiconFile) throws IOException {
this(ImmutableTable.copyOf(loadLexicon(lexiconFile)));
}
public Table<StateExpr, StateExpr, Transition> getForwardEdgeTable() {
return ImmutableTable.copyOf(_forwardEdgeTable);
}
@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));
}
@Encoding.Of
static <R, C, V> ImmutableTable<R, C, V> init(Table<? extends R, ? extends C, ? extends V> table) {
return ImmutableTable.copyOf(table);
}
/**
* 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));
}