List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:bear.plugins.sh.SystemSession.java
public String joinPath(Iterable<?> varsAndObjects) { return joinPath(Iterables.toArray(varsAndObjects, Object.class)); }
From source file:org.blip.workflowengine.transferobject.ModifiablePropertyNode.java
@Override public PropertyNode add(final String key, final Integer value, final Collection<Attribute> attributes) { return internalAdd(true, key, value, Iterables.toArray(attributes, Attribute.class)); }
From source file:org.kitesdk.morphline.base.Configs.java
public Locale getLocale(Config config, String path) { addRecognizedArgument(path);/*from www.java 2 s.c o m*/ String str = config.getString(path); String[] parts = Iterables.toArray(Splitter.on('_').split(str), String.class); if (parts.length == 1) { return new Locale(parts[0]); } else if (parts.length == 2) { return new Locale(parts[0], parts[1]); } else if (parts.length == 3) { return new Locale(parts[0], parts[1], parts[2]); } else { throw new MorphlineCompilationException("Illegal locale: " + str, config); } }
From source file:org.apache.hadoop.yarn.webapp.Dispatcher.java
private void setMoreParams(RequestContext rc, String pathInfo, Dest dest) { checkState(pathInfo.startsWith(dest.prefix), "prefix should match"); if (dest.pathParams.size() == 0 || dest.prefix.length() == pathInfo.length()) { return;//from w w w . ja va 2s .c o m } String[] parts = Iterables.toArray(WebApp.pathSplitter.split(pathInfo.substring(dest.prefix.length())), String.class); LOG.debug("parts={}, params={}", parts, dest.pathParams); for (int i = 0; i < dest.pathParams.size() && i < parts.length; ++i) { String key = dest.pathParams.get(i); if (key.charAt(0) == ':') { rc.moreParams().put(key.substring(1), parts[i]); } } }
From source file:com.google.devtools.build.lib.runtime.AllIncompatibleChangesExpansion.java
@Override public String[] getExpansion(IsolatedOptionsData optionsData) { // Grab all registered options that are identified as incompatible changes by either name or // by category. Ensure they satisfy our requirements. ArrayList<String> incompatibleChanges = new ArrayList<>(); for (Map.Entry<String, Field> entry : optionsData.getAllNamedFields()) { Field field = entry.getValue(); Option annotation = field.getAnnotation(Option.class); if (annotation.name().startsWith(INCOMPATIBLE_NAME_PREFIX) || annotation.category().equals(INCOMPATIBLE_CATEGORY)) { validateIncompatibleChange(field, annotation); incompatibleChanges.add("--" + annotation.name()); }/*from w ww . j av a2s.c o m*/ } // Sort to get a deterministic canonical order. This probably isn't necessary because the // options parser will do its own sorting when canonicalizing, but it seems like it can't hurt. incompatibleChanges.sort(null); return Iterables.toArray(incompatibleChanges, String.class); }
From source file:org.polymap.core.catalog.ui.FileUploadPage.java
private CCombo createCharsetCombo(Composite parent) { charsetCombo = new CCombo(parent, SWT.BORDER | SWT.READ_ONLY); charsetCombo.setToolTipText(i18n.get("charsetTip")); ArrayList items = new ArrayList(256); int first = 0; for (String input : Charset.availableCharsets().keySet()) { if (input.toLowerCase().startsWith(charsetCombo.getText().toLowerCase())) { items.add(input);/*w ww. ja v a 2 s. co m*/ first = input.equals("UTF-8") ? items.size() - 1 : first; } } charsetCombo.setItems(Iterables.toArray(items, String.class)); charsetCombo.setVisibleItemCount(17); charsetCombo.select(first); return charsetCombo; }
From source file:edu.umn.msi.tropix.webgui.server.ObjectServiceImpl.java
@ServiceMethod public void cloneAsSharedFolder(final String folderId, final List<String> userIds, final List<String> groupIds) { this.tropixObjectService.cloneAsSharedFolder(this.userSession.getGridId(), folderId, Iterables.toArray(userIds, String.class), Iterables.toArray(groupIds, String.class)); }
From source file:org.apache.maven.DefaultMaven.java
private MavenExecutionResult doExecute(MavenExecutionRequest request, MavenSession session, MavenExecutionResult result, DefaultRepositorySystemSession repoSession) { try {/* w w w. j a v a 2s. c o m*/ for (AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList())) { listener.afterSessionStart(session); } } catch (MavenExecutionException e) { return addExceptionToResult(result, e); } eventCatapult.fire(ExecutionEvent.Type.ProjectDiscoveryStarted, session, null); Result<? extends ProjectDependencyGraph> graphResult = buildGraph(session, result); if (graphResult.hasErrors()) { return addExceptionToResult(result, Iterables.toArray(graphResult.getProblems(), ModelProblem.class)[0].getException()); } try { session.setProjectMap(getProjectMap(session.getProjects())); } catch (DuplicateProjectException e) { return addExceptionToResult(result, e); } WorkspaceReader reactorWorkspace; try { reactorWorkspace = container.lookup(WorkspaceReader.class, ReactorReader.HINT); } catch (ComponentLookupException e) { return addExceptionToResult(result, e); } // // Desired order of precedence for local artifact repositories // // Reactor // Workspace // User Local Repository // repoSession.setWorkspaceReader( ChainedWorkspaceReader.newInstance(reactorWorkspace, repoSession.getWorkspaceReader())); repoSession.setReadOnly(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { for (AbstractMavenLifecycleParticipant listener : getLifecycleParticipants(session.getProjects())) { Thread.currentThread().setContextClassLoader(listener.getClass().getClassLoader()); listener.afterProjectsRead(session); } } catch (MavenExecutionException e) { return addExceptionToResult(result, e); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } // // The projects need to be topologically after the participants have run their afterProjectsRead(session) // because the participant is free to change the dependencies of a project which can potentially change the // topological order of the projects, and therefore can potentially change the build order. // // Note that participants may affect the topological order of the projects but it is // not expected that a participant will add or remove projects from the session. // graphResult = buildGraph(session, result); if (graphResult.hasErrors()) { return addExceptionToResult(result, Iterables.toArray(graphResult.getProblems(), ModelProblem.class)[0].getException()); } try { if (result.hasExceptions()) { return result; } result.setTopologicallySortedProjects(session.getProjects()); result.setProject(session.getTopLevelProject()); lifecycleStarter.execute(session); validateActivatedProfiles(session.getProjects(), request.getActiveProfiles()); if (session.getResult().hasExceptions()) { return addExceptionToResult(result, session.getResult().getExceptions().get(0)); } } finally { try { afterSessionEnd(session.getProjects(), session); } catch (MavenExecutionException e) { return addExceptionToResult(result, e); } } return result; }
From source file:org.apache.parquet.cli.Util.java
public static PrimitiveType primitive(String column, MessageType schema) { String[] path = Iterables.toArray(DOT.split(column), String.class); Preconditions.checkArgument(schema.containsPath(path), "Schema doesn't have column: " + column); return primitive(schema, path); }
From source file:com.dangdang.ddframe.job.api.config.impl.AbstractJobConfigurationGsonTypeAdapter.java
private JobEventConfiguration[] getJobEventConfigs(final JsonReader in) throws IOException { List<JobEventConfiguration> result = new ArrayList<>(2); in.beginObject();/* ww w .j a va 2s .c o m*/ while (in.hasNext()) { String name = in.nextName(); switch (name) { case "log": in.beginObject(); result.add(new JobLogEventConfiguration()); in.endObject(); break; case "rdb": String url = ""; String username = ""; String password = ""; String driverClassName = ""; String logLevel = ""; in.beginObject(); while (in.hasNext()) { switch (in.nextName()) { case "url": url = in.nextString(); break; case "username": username = in.nextString(); break; case "password": password = in.nextString(); break; case "driverClassName": driverClassName = in.nextString(); break; case "logLevel": logLevel = in.nextString(); break; default: break; } } in.endObject(); result.add(new JobRdbEventConfiguration(driverClassName, url, username, password, LogLevel.valueOf(logLevel.toUpperCase()))); break; default: break; } } in.endObject(); return Iterables.toArray(result, JobEventConfiguration.class); }