List of usage examples for java.util Collection toArray
default <T> T[] toArray(IntFunction<T[]> generator)
From source file:grails.util.GrailsClassUtils.java
/** * Convenience method for converting a collection to an Object[] * @param c The collection/*from w w w . j a va 2s . co m*/ * @return An object array */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static Object[] collectionToObjectArray(Collection c) { if (c == null) return new Object[0]; return c.toArray(new Object[c.size()]); }
From source file:graphene.util.fs.FileUtils.java
public static File[] deleteFiles(final File directory, final String regexPattern) throws IOException { final Pattern pattern = Pattern.compile(regexPattern); final Collection<File> deletedFiles = new ArrayList<>(); final File[] files = directory.listFiles(); if (files == null) { throw new IllegalArgumentException(directory + " is not a directory"); }/*ww w . j ava 2 s .co m*/ for (final File file : files) { if (pattern.matcher(file.getName()).find()) { if (!file.delete()) { throw new IOException("Couldn't delete file '" + file.getAbsolutePath() + "'"); } deletedFiles.add(file); } } return deletedFiles.toArray(new File[deletedFiles.size()]); }
From source file:com.google.dart.engine.internal.search.scope.LibrarySearchScope.java
/** * Create a search scope that encompasses everything in the given libraries. * /*from w ww. j a v a2 s . c o m*/ * @param libraries the libraries defining which elements are included in the scope */ public LibrarySearchScope(Collection<LibraryElement> libraries) { this(libraries.toArray(new LibraryElement[libraries.size()])); }
From source file:hwolf.spring.boot.servlet.ServletContainerInitializerInvoker.java
public ServletContainerInitializerInvoker(ServletContainerInitializer initializer, Collection<String> basePackages) { this(initializer, basePackages.toArray(new String[0])); }
From source file:com.espertech.esper.regression.enummethod.TestExpressionDefLambdaLocReport.java
private Item[] itemArray(Collection<Item> it) { return it.toArray(new Item[it.size()]); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java
/** * Get all the distinct company names that vendors are associated with. *///w ww . j av a2s. co m public static String[] getCompanyNames() throws EnvoyServletException { try { Collection cns = ServerProxy.getVendorManagement().getCompanyNames(); String[] cnArray = new String[cns.size()]; cnArray = (String[]) cns.toArray(cnArray); return cnArray; } catch (Exception e) { throw new EnvoyServletException(e); } }
From source file:org.sakaiproject.metaobj.utils.ioc.ApplicationContextFactory.java
protected String[] convertToArray(Collection collection) { return (String[]) collection.toArray(new String[collection.size()]); }
From source file:io.github.tavernaextras.biocatalogue.integration.Integration.java
/** * @param activityPort Probably comes from contextual selection - must be either * ActivityInputPort or ActivityOutputPort. * @return SOAP input / output port details (WSDL location, operation name, port name) from * ActivityInputPort/ActivityOutputPort which is obtained from contextual selection in the Dataflow. *///ww w .ja va 2 s.com public static <T extends Port> SoapOperationPortIdentity extractSoapOperationPortDetailsFromActivityInputOutputPort( T activityPort) { // check that we have the correct instance of Port here - either ActivityInputPort or ActivityOutputPort boolean hasInputPort; if (activityPort instanceof ActivityInputPort) { hasInputPort = true; } else if (activityPort instanceof ActivityOutputPort) { hasInputPort = false; } else { // ERROR - wrong type supplied return new SoapOperationPortIdentity( "Activity port from the contextual selection was not of correct type. Impossible to create preview."); } // get parent processor details Dataflow currentDataflow = FileManager.getInstance().getCurrentDataflow(); Collection<Processor> processors = null; if (hasInputPort) { processors = Tools.getProcessorsWithActivityInputPort(currentDataflow, (ActivityInputPort) activityPort); } else { processors = Tools.getProcessorsWithActivityOutputPort(currentDataflow, (ActivityOutputPort) activityPort); } // TODO - doesn't take into account that it's possible to have several SoapOperationIdentity soapOperationDetails = extractSoapOperationDetailsFromProcessor( processors.toArray(new Processor[] {})[0]); // if no error happened, add port details and return if (!soapOperationDetails.hasError()) { return (new SoapOperationPortIdentity(soapOperationDetails.getWsdlLocation(), soapOperationDetails.getOperationName(), activityPort.getName(), hasInputPort)); } else { // error... return (new SoapOperationPortIdentity(soapOperationDetails.getErrorDetails())); } }
From source file:com.opensearchserver.hadse.cluster.NodeItem.java
NodeItem(Collection<String> addresses) { this.addresses = addresses == null ? null : addresses.toArray(new String[addresses.size()]); }
From source file:com.kuzumeji.framework.enterprise.component.persistence.bak.DefaultUniqueConstraintsListener.java
/** * {@inheritDoc}/*from w w w. j a v a 2 s. co m*/ * <dl> * <dt>? * <dd>?????? * </dl> */ @Override public Object[] values(final P object) { final Collection<Object> values = filter(object).values(); return values.toArray(new Object[values.size()]); }