List of usage examples for com.google.common.collect Lists transform
@CheckReturnValue public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function)
From source file:com.dangdang.ddframe.rdb.sharding.router.binding.BindingRoutingDataSource.java
BindingRoutingDataSource(final SingleRoutingDataSource routingDataSource) { super(routingDataSource.getDataSource()); getRoutingTableFactors().addAll(Lists.transform(routingDataSource.getRoutingTableFactors(), new Function<SingleRoutingTableFactor, BindingRoutingTableFactor>() { @Override//from ww w.j av a2 s. c om public BindingRoutingTableFactor apply(final SingleRoutingTableFactor input) { return new BindingRoutingTableFactor(input.getLogicTable(), input.getActualTable()); } })); }
From source file:io.druid.query.topn.TopNResultValue.java
@JsonCreator public TopNResultValue(List<?> value) { this.value = (value == null) ? Lists.<DimensionAndMetricValueExtractor>newArrayList() : Lists.transform(value, new Function<Object, DimensionAndMetricValueExtractor>() { @Override/*from w w w . j ava2 s . co m*/ public DimensionAndMetricValueExtractor apply(@Nullable Object input) { if (input instanceof Map) { return new DimensionAndMetricValueExtractor((Map) input); } else if (input instanceof DimensionAndMetricValueExtractor) { return (DimensionAndMetricValueExtractor) input; } else { throw new IAE("Unknown type for input[%s]", input.getClass()); } } }); }
From source file:com.ebuddy.cassandra.structure.DefaultPath.java
/** Create a DefaultPath from un-encoded string elements. */ public static DefaultPath fromStrings(String... elements) { return new DefaultPath(Lists.transform(Arrays.asList(elements), urlEncodeFunction)); }
From source file:org.jetbrains.jet.plugin.navigation.ImplementationTestUtils.java
public static void assertGotoImplementations(Editor editor, GotoTargetHandler.GotoData gotoData) { // Get expected references from the tested document List<String> expectedReferences = Arrays .asList(InTextDirectivesUtils.findListWithPrefix("// REF:", editor.getDocument().getText())); Collections.sort(expectedReferences); if (gotoData != null) { // Transform given reference result to strings List<String> psiElements = Lists.transform(Arrays.asList(gotoData.targets), new Function<PsiElement, String>() { @Override//from ww w . j av a2 s . co m public String apply(@Nullable PsiElement element) { Assert.assertNotNull(element); if (element instanceof JetLightClass) { JetLightClass jetLightClass = (JetLightClass) element; JetLightClassListCellRenderer renderer = new JetLightClassListCellRenderer(); String elementText = renderer.getElementText(jetLightClass); String containerText = JetLightClassListCellRenderer .getContainerTextStatic(jetLightClass); return (containerText != null) ? containerText + "." + elementText : elementText; } Assert.assertTrue(element instanceof NavigationItem); ItemPresentation presentation = ((NavigationItem) element).getPresentation(); Assert.assertNotNull(presentation); String presentableText = presentation.getPresentableText(); String locationString = presentation.getLocationString(); return locationString != null ? (locationString + "." + presentableText) : presentableText; } }); // Compare UsefulTestCase.assertOrderedEquals(Ordering.natural().sortedCopy(psiElements), expectedReferences); } else { UsefulTestCase.assertEmpty(expectedReferences); } }
From source file:com.facebook.presto.metadata.PartitionResult.java
public PartitionResult(String connectorId, ConnectorPartitionResult connectorPartitionResult) { Preconditions.checkNotNull(connectorId, "connectorId is null"); Preconditions.checkNotNull(connectorPartitionResult, "connectorPartitionResult is null"); partitions = Lists.transform(connectorPartitionResult.getPartitions(), fromConnectorPartition(connectorId)); undeterminedTupleDomain = fromConnectorDomain(connectorId, connectorPartitionResult.getUndeterminedTupleDomain()); }
From source file:io.druid.query.groupby.GroupByQueryHelper.java
public static <T> Pair<IncrementalIndex, Accumulator<IncrementalIndex, T>> createIndexAccumulatorPair( final GroupByQuery query, final GroupByQueryConfig config, StupidPool<ByteBuffer> bufferPool ) {/*from w w w . j a v a 2 s . com*/ final QueryGranularity gran = query.getGranularity(); final long timeStart = query.getIntervals().get(0).getStartMillis(); // use gran.iterable instead of gran.truncate so that // AllGranularity returns timeStart instead of Long.MIN_VALUE final long granTimeStart = gran.iterable(timeStart, timeStart + 1).iterator().next(); final List<AggregatorFactory> aggs = Lists.transform(query.getAggregatorSpecs(), new Function<AggregatorFactory, AggregatorFactory>() { @Override public AggregatorFactory apply(AggregatorFactory input) { return input.getCombiningFactory(); } }); final List<String> dimensions = Lists.transform(query.getDimensions(), new Function<DimensionSpec, String>() { @Override public String apply(DimensionSpec input) { return input.getOutputName(); } }); final IncrementalIndex index; if (query.getContextValue("useOffheap", false)) { index = new OffheapIncrementalIndex( // use granularity truncated min timestamp // since incoming truncated timestamps may precede timeStart granTimeStart, gran, aggs.toArray(new AggregatorFactory[aggs.size()]), bufferPool, false, Integer.MAX_VALUE); } else { index = new OnheapIncrementalIndex( // use granularity truncated min timestamp // since incoming truncated timestamps may precede timeStart granTimeStart, gran, aggs.toArray(new AggregatorFactory[aggs.size()]), false, config.getMaxResults()); } Accumulator<IncrementalIndex, T> accumulator = new Accumulator<IncrementalIndex, T>() { @Override public IncrementalIndex accumulate(IncrementalIndex accumulated, T in) { if (in instanceof MapBasedRow) { try { MapBasedRow row = (MapBasedRow) in; accumulated.add(new MapBasedInputRow(row.getTimestamp(), dimensions, row.getEvent())); } catch (IndexSizeExceededException e) { throw new ISE(e.getMessage()); } } else { throw new ISE("Unable to accumulate something of type [%s]", in.getClass()); } return accumulated; } }; return new Pair<>(index, accumulator); }
From source file:br.com.objectos.way.io.IsXlsWritableLineBuilder.java
public <T extends IsXlsWritable> List<String> transform(List<T> writables) { List<Row> moreRows;/*from ww w . j a v a2 s. c o m*/ moreRows = Lists.transform(writables, new IsXlsWritableToRow()); rows.addAll(moreRows); List<String> strings; strings = Lists.transform(rows, Functions.toStringFunction()); return ImmutableList.copyOf(strings); }
From source file:org.apache.kylin.tool.metrics.systemcube.ProjectCreator.java
public static ProjectInstance generateKylinProjectInstance(String owner, List<TableDesc> kylinTables, List<DataModelDesc> kylinModels, List<CubeDesc> kylinCubeDescs) { ProjectInstance projectInstance = new ProjectInstance(); projectInstance.setName(MetricsManager.SYSTEM_PROJECT); projectInstance.setOwner(owner);/* ww w . j a v a2 s . c o m*/ projectInstance.setDescription(SYSTEM_PROJECT_DESC); projectInstance.setStatus(ProjectStatusEnum.ENABLED); projectInstance.setCreateTimeUTC(0L); projectInstance.updateRandomUuid(); if (kylinTables != null) projectInstance .setTables(Sets.newHashSet(Lists.transform(kylinTables, new Function<TableDesc, String>() { @Nullable @Override public String apply(@Nullable TableDesc tableDesc) { if (tableDesc != null) { return tableDesc.getIdentity(); } return null; } }))); else projectInstance.setTables(Sets.<String>newHashSet()); if (kylinModels != null) projectInstance.setModels(Lists.transform(kylinModels, new Function<DataModelDesc, String>() { @Nullable @Override public String apply(@Nullable DataModelDesc modelDesc) { if (modelDesc != null) { return modelDesc.getName(); } return null; } })); else projectInstance.setModels(Lists.<String>newArrayList()); if (kylinCubeDescs != null) projectInstance.setRealizationEntries( Lists.transform(kylinCubeDescs, new Function<CubeDesc, RealizationEntry>() { @Nullable @Override public RealizationEntry apply(@Nullable CubeDesc cubeDesc) { if (cubeDesc != null) { RealizationEntry entry = new RealizationEntry(); entry.setRealization(cubeDesc.getName()); entry.setType(RealizationType.CUBE); return entry; } return null; } })); else projectInstance.setRealizationEntries(Lists.<RealizationEntry>newArrayList()); return projectInstance; }
From source file:com.google.jstestdriver.DryRunInfo.java
/** * @return the testNames/*from w ww . j av a 2 s .c o m*/ */ public List<String> getTestNames() { return Lists.transform(testCases, new Function<TestCase, String>() { @Override public String apply(TestCase tc) { return tc.toString(); } }); }
From source file:org.apache.samza.sql.interfaces.SamzaSqlJavaTypeFactoryImpl.java
private static RelDataType convertToSql(final RelDataTypeFactory typeFactory, RelDataType type) { if (type instanceof RelRecordType) { return typeFactory.createStructType( Lists.transform(type.getFieldList(), a0 -> convertToSql(typeFactory, a0.getType())), type.getFieldNames());/* ww w . ja va 2 s . c o m*/ } if (type instanceof JavaType) { SqlTypeName typeName = JavaToSqlTypeConversionRules.instance().lookup(((JavaType) type).getJavaClass()); // For unknown sql type names, return ANY sql type to make Calcite validation not fail. if (typeName == null) { typeName = SqlTypeName.ANY; } return typeFactory.createTypeWithNullability(typeFactory.createSqlType(typeName), type.isNullable()); } else { return JavaTypeFactoryImpl.toSql(typeFactory, type); } }