List of usage examples for com.google.common.base Functions toStringFunction
public static Function<Object, String> toStringFunction()
From source file:com.facebook.buck.simulate.BuildSimulator.java
public SimulateReport simulateBuild(long currentTimeMillis, ImmutableList<BuildTarget> buildTargets) { Preconditions.checkArgument(buildTargets.size() > 0, "No targets provided for the simulation."); SimulateReport.Builder simulateReport = SimulateReport.builder(); for (String timeAggregate : times.getTimeAggregates()) { // Setup the build order. Map<BuildTarget, NodeState> reverseDependencies = Maps.newHashMap(); Queue<BuildTarget> leafNodes = Queues.newArrayDeque(); int totalDagEdges = 0; for (BuildTarget target : buildTargets) { BuildRule rule;/*from w w w . ja v a 2s .c o m*/ try { rule = resolver.requireRule(target); } catch (NoSuchBuildTargetException e) { throw new HumanReadableException(e.getHumanReadableErrorMessage()); } totalDagEdges += recursiveTraversal(rule, reverseDependencies, leafNodes); } SingleRunReport.Builder report = SingleRunReport.builder().setTimestampMillis(currentTimeMillis) .setBuildTargets(FluentIterable.from(buildTargets).transform(Functions.toStringFunction())) .setSimulateTimesFile(times.getFile()) .setRuleFallbackTimeMillis(times.getRuleFallbackTimeMillis()) .setTotalActionGraphNodes(Iterables.size(actionGraph.getNodes())) .setTimeAggregate(timeAggregate).setNumberOfThreads(numberOfThreads); report.setTotalDependencyDagEdges(totalDagEdges); // Run the simulation. simulateReport.addRunReports(runSimulation(report, reverseDependencies, leafNodes, timeAggregate)); } return simulateReport.build(); }
From source file:org.fao.geonet.services.category.Remove.java
@RequestMapping(value = "/{lang}/admin.category.remove", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @ResponseBody//from w w w. j a v a 2 s .c om public CategoryUpdateResponse exec(@RequestParam Integer id) throws Exception { if (id == null) { throw new IllegalArgumentException("parameter id is required"); } ConfigurableApplicationContext appContext = ApplicationContextHolder.get(); MetadataCategoryRepository categoryRepository = appContext.getBean(MetadataCategoryRepository.class); IMetadataUtils metadataRepository = appContext.getBean(IMetadataUtils.class); DataManager dataManager = appContext.getBean(DataManager.class); final MetadataCategory category = categoryRepository.findOne(id); final List<Integer> affectedMd = metadataRepository.findAllIdsBy(MetadataSpecs.hasCategory(category)); categoryRepository.deleteCategoryAndMetadataReferences(id); //--- reindex affected metadata dataManager.indexMetadata(Lists.transform(affectedMd, Functions.toStringFunction())); CategoryUpdateResponse response = new CategoryUpdateResponse(); response.addOperation(CategoryUpdateResponse.Operation.removed); return response; }
From source file:ei.ne.ke.cassandra.cql3.template.BatchStatementBuilder.java
/** * {@inheritDoc}/*from ww w.jav a 2 s . c om*/ */ @Override public String build() { Preconditions.checkArgument(!statements.isEmpty(), "You must provide at least one statement"); StringBuilder sb = new StringBuilder(); sb.append("BEGIN "); if (unlogged) { sb.append("UNLOGGED "); } sb.append("BATCH "); if (options.size() > 0) { sb.append("USING "); sb.append(StringUtils.join(Collections2.transform(options, Functions.toStringFunction()), " AND ")); } for (Mutating statement : statements) { if (statement.usingTimestamp()) { throw new IllegalArgumentException( "When batching, you cannot set a timestamp on individual statements."); } sb.append(" "); sb.append(statement.build()); } sb.append(" APPLY BATCH;"); return sb.toString(); }
From source file:com.google.devtools.build.lib.syntax.GlobCriteria.java
/** * Constructs a copy of a fixed list, converted to Strings. *//* w w w . j a va 2 s . c om*/ public static GlobCriteria fromList(Iterable<?> list) { Iterable<String> strings = Iterables.transform(list, Functions.toStringFunction()); return new GlobCriteria(ImmutableList.copyOf(strings), ImmutableList.<String>of(), false); }
From source file:com.android.tools.idea.ui.ASGallery.java
public ASGallery() { this(new DefaultListModel(), Functions.<Image>constant(null), Functions.toStringFunction(), new Dimension(0, 0), null); }
From source file:br.com.objectos.comuns.relational.jdbc.JdbcConfigure.java
private Collection<String> getStrings(Class<?> keyClass) { Collection<Element> els = sql.getElements(keyClass); return Collections2.transform(els, Functions.toStringFunction()); }
From source file:edu.harvard.med.screensaver.ui.arch.util.JSFUtils.java
/** * Creates a UISelectItems object that can be assigned to the "value" * attribute of a UISelectItems JSF component. Adds an additional * "empty selection" item, whose value is an empty string and label is as * specified (empty string if null)./*from w w w. j ava 2 s. c o m*/ */ public static List<SelectItem> createUISelectItemsWithEmptySelection(Collection<?> items, String emptySelectionLabel) { return createUISelectItems(items, true, emptySelectionLabel, Functions.toStringFunction()); }
From source file:com.nesscomputing.mojo.numbers.beans.PropertyGroup.java
public Iterator<String> getPropertyNames() { return Iterators.transform(properties.keySet().iterator(), Functions.toStringFunction()); }
From source file:org.fao.geonet.services.group.Remove.java
public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception { String id = Util.getParam(params, Params.ID); OperationAllowedRepository operationAllowedRepo = context.getBean(OperationAllowedRepository.class); UserGroupRepository userGroupRepo = context.getBean(UserGroupRepository.class); GroupRepository groupRepo = context.getBean(GroupRepository.class); Integer iId = Integer.valueOf(id); List<Integer> reindex = operationAllowedRepo.findAllIds(OperationAllowedSpecs.hasGroupId(iId), OperationAllowedId_.metadataId); operationAllowedRepo.deleteAllByIdAttribute(OperationAllowedId_.groupId, iId); userGroupRepo.deleteAllByIdAttribute(UserGroupId_.groupId, Arrays.asList(iId)); groupRepo.delete(iId);//w ww. j ava2s .com //--- reindex affected metadata GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); DataManager dm = gc.getBean(DataManager.class); dm.indexMetadata(Lists.transform(reindex, Functions.toStringFunction())); return new Element(Jeeves.Elem.RESPONSE) .addContent(new Element(Jeeves.Elem.OPERATION).setText(Jeeves.Text.REMOVED)); }
From source file:com.googlecode.blaisemath.graph.testui.GraphTestFrame.java
/** Creates new form TestPlaneVisometry */ public GraphTestFrame() { EditorRegistration.registerEditors(); initComponents();/*from w w w . j a va 2 s . c o m*/ // BASIC ELEMENTS final Graph<Integer> graph = new EdgeProbabilityGraphSupplier(false, 50, .05f).get(); plot.setGraph(graph); plot.getAdapter().getViewGraph().setDragEnabled(true); plot.getLayoutManager().applyLayout(StaticGraphLayout.CIRCLE, Collections.EMPTY_MAP, Collections.EMPTY_SET, 100.0); PanAndZoomHandler.zoomBoxAnimated(plot, Points.boundingBox(plot.getLayoutManager().getNodeLocationCopy().values(), 5)); plot.getAdapter().getNodeStyler().setStyleDelegate(new Function<Object, AttributeSet>() { public AttributeSet apply(Object o) { Integer i = (Integer) o; return Styles.DEFAULT_POINT_STYLE.copy().and(Styles.FILL, Color.lightGray) .and(Styles.STROKE, Color.gray).and(Styles.STROKE_WIDTH, .5f) .and(Styles.MARKER_RADIUS, 2 + Math.sqrt(i)); } }); plot.getAdapter().getNodeStyler().setLabelDelegate(Functions.toStringFunction()); plot.addContextMenuInitializer("Graph", new ContextMenuInitializer<Graphic>() { public void initContextMenu(JPopupMenu menu, Graphic src, Point2D point, Object focus, Set selection) { if (menu.getComponentCount() > 0) { menu.addSeparator(); } if (focus != null) { menu.add("Graph Focus: " + focus); } menu.add("Selection: " + (selection == null ? 0 : selection.size()) + " selected items"); } }); plot.addContextMenuInitializer("Node", new ContextMenuInitializer<Graphic>() { public void initContextMenu(JPopupMenu menu, Graphic src, Point2D point, Object focus, Set selection) { if (menu.getComponentCount() > 0) { menu.addSeparator(); } if (focus != null) { menu.add("Node: " + focus); } } }); plot.addContextMenuInitializer("Link", new ContextMenuInitializer<Graphic>() { public void initContextMenu(JPopupMenu menu, Graphic src, Point2D point, Object focus, Set selection) { if (menu.getComponentCount() > 0) { menu.addSeparator(); } if (focus != null) { menu.add("Link: " + focus); } } }); // PANELS rollupPanel1.add("Energy Layout", PropertySheet .forBean(energyLayout = new SpringLayout(plot.getLayoutManager().getNodeLocationCopy()))); for (Graphic p : plot.getGraphicRoot().getGraphics()) { rollupPanel1.add(p.toString(), PropertySheet.forBean(p)); } addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { GAInstrument.print(System.out, 50); } }); // OVERLAY plot.getOverlays().add(new CanvasPainter<Graphics2D>() { public void paint(Component component, Graphics2D canvas) { canvas.setColor(Color.black); canvas.drawLine(50, 50, 150, 50); canvas.drawLine(50, 40, 50, 60); canvas.drawLine(150, 40, 150, 60); } }); }