List of usage examples for com.google.common.collect Collections2 transform
public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function)
From source file:com.dangdang.ddframe.rdb.sharding.router.database.DatabaseRoutingResult.java
@Override public Collection<SQLExecutionUnit> getSQLExecutionUnits(final SQLBuilder sqlBuilder) { return Collections2.transform(routedDatabaseNames, new Function<String, SQLExecutionUnit>() { @Override/*from ww w. ja v a2 s . co m*/ public SQLExecutionUnit apply(final String input) { return new SQLExecutionUnit(input, sqlBuilder); } }); }
From source file:org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils.java
public static void checkForUnexpectedErrors(JetFile file) { if (!InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// DISABLE-ERRORS").isEmpty()) { return;/* ww w .j av a 2 s . c om*/ } Collection<Diagnostic> diagnostics = ResolvePackage.analyzeFully(file).getDiagnostics().all(); Collection<Diagnostic> errorDiagnostics = Collections2.filter(diagnostics, new Predicate<Diagnostic>() { @Override public boolean apply(@Nullable Diagnostic diagnostic) { assert (diagnostic != null); return diagnostic.getSeverity() == Severity.ERROR; } }); Collection<String> actualErrorStrings = Collections2.transform(errorDiagnostics, new Function<Diagnostic, String>() { @Override public String apply(@Nullable Diagnostic diagnostic) { assert (diagnostic != null); return IdeErrorMessages.render(diagnostic); } }); List<String> expectedErrorStrings = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ERROR:"); Collections.sort(expectedErrorStrings); UsefulTestCase.assertOrderedEquals( "All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned", Ordering.natural().sortedCopy(actualErrorStrings), expectedErrorStrings); }
From source file:gt.org.ms.controller.roles.handlers.CrearHandler.java
@Override public Role execute(final RoleDto request) { final Role r = new RoleDtoConverter().toEntity(request); r.setAccesoRoleCollection(// w w w . j ava 2 s .c om Collections2.transform(request.getAccesos(), new Function<AccesoDto, AccesoRole>() { @Override public AccesoRole apply(AccesoDto f) { AccesoRole acceso = new AccesoRole(); acceso.setFkAcceso(accesos.findOne(f.getId())); acceso.setFkRole(r); acceso.setCreadoPor(request.getUsuario()); EntitiesHelper.setDateCreatedInfo(acceso); EntitiesHelper.setDateUpdatedInfo(acceso); return acceso; } })); EntitiesHelper.setDateCreatedInfo(r); r.setEstado(Estado.ACTIVO); roles.save(r); return r; }
From source file:gt.org.ms.controller.roles.handlers.BuscarTodosHandler.java
@Override public List<RoleDto> execute(final Object request) { return new ArrayList<RoleDto>(Collections2.transform(roles.findAll(new NoDisableEntitiesSpec<Role>()), new Function<Role, RoleDto>() { @Override//from w ww.j a v a 2 s . c o m public RoleDto apply(Role r) { RoleDto rd = new RoleDtoConverter().toDTO(r); rd.setAccesos(new ArrayList(Collections2.transform(r.getAccesoRoleCollection(), new Function<AccesoRole, AccesoDto>() { @Override public AccesoDto apply(AccesoRole f) { return new AccesoDtoConverter().toDTO(f.getFkAcceso()); } }))); return rd; } })); }
From source file:biz.ganttproject.impex.csv.GanttCSVOpen.java
static Collection<String> getFieldNames(Enum... fieldsEnum) { return Collections2.transform(Arrays.asList(fieldsEnum), new Function<Enum, String>() { @Override/* ww w .jav a 2 s . c om*/ public String apply(Enum input) { return input.toString(); } }); }
From source file:com.anathema_roguelike.characters.abilities.AbilitySet.java
public <T extends Ability> Collection<T> get(final Class<T> superclass) { return Collections2.transform(CollectionUtils.filterByClass(abilities, superclass), new Function<T, T>() { @Override/*from w ww .j ava 2 s . com*/ public T apply(T input) { T ret = input; return ret; } }); }
From source file:org.opendaylight.netconf.monitoring.xml.model.MonitoringSchema.java
@XmlElement(name = "location") public Collection<String> getLocation() { return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() { @Nullable/*from w w w .j a v a 2s. c o m*/ @Override public String apply(@Nonnull Schema.Location input) { return input.getEnumeration().toString(); } }); }
From source file:gt.org.ms.controller.roles.handlers.BuscarHandler.java
@Override public RoleDto execute(final RoleDto request) { Role r;// www.j av a 2s . c o m RoleDto rd = new RoleDtoConverter().toDTO(r = roles.findOne(request.getId())); rd.setAccesos(new ArrayList( Collections2.transform(r.getAccesoRoleCollection(), new Function<AccesoRole, AccesoDto>() { @Override public AccesoDto apply(AccesoRole f) { return new AccesoDtoConverter().toDTO(f.getFkAcceso()); } }))); return rd; }
From source file:org.gradle.api.tasks.diagnostics.internal.graph.nodes.InvertedRenderableModuleResult.java
public Set<RenderableDependency> getChildren() { return new LinkedHashSet<RenderableDependency>(Collections2.transform(module.getDependents(), new Function<DependencyResult, RenderableDependency>() { public RenderableDependency apply(DependencyResult input) { return new InvertedRenderableModuleResult(input.getFrom()); }/*from www. ja va 2s . c o m*/ })); }
From source file:org.jetbrains.jet.plugin.DirectiveBasedActionUtils.java
public static void checkForUnexpectedErrors(JetFile file) { if (!InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// DISABLE-ERRORS").isEmpty()) { return;//w w w .j a va2 s .co m } AnalyzeExhaust exhaust = AnalyzerFacadeWithCache.analyzeFileWithCache(file); Collection<Diagnostic> diagnostics = exhaust.getBindingContext().getDiagnostics().all(); Collection<Diagnostic> errorDiagnostics = Collections2.filter(diagnostics, new Predicate<Diagnostic>() { @Override public boolean apply(@Nullable Diagnostic diagnostic) { assert (diagnostic != null); return diagnostic.getSeverity() == Severity.ERROR; } }); Collection<String> actualErrorStrings = Collections2.transform(errorDiagnostics, new Function<Diagnostic, String>() { @Override public String apply(@Nullable Diagnostic diagnostic) { assert (diagnostic != null); return IdeErrorMessages.RENDERER.render(diagnostic); } }); List<String> expectedErrorStrings = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ERROR:"); Collections.sort(expectedErrorStrings); UsefulTestCase.assertOrderedEquals( "All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned", Ordering.natural().sortedCopy(actualErrorStrings), expectedErrorStrings); }