List of usage examples for java.util Collection toArray
default <T> T[] toArray(IntFunction<T[]> generator)
From source file:org.commonjava.indy.diags.ftest.DownloadDiagBundleTest.java
protected Indy createIndyClient() throws IndyClientException { SiteConfig config = new SiteConfigBuilder("indy", fixture.getUrl()).withRequestTimeoutSeconds(120).build(); Collection<IndyClientModule> modules = getAdditionalClientModules(); return new Indy(config, new MemoryPasswordManager(), new IndyObjectMapper(getAdditionalMapperModules()), modules.toArray(new IndyClientModule[modules.size()])); }
From source file:org.solmix.runtime.cm.support.SpringConfigureUnitManager.java
@Override public ConfigureUnit[] listConfigureUnits(String filter) throws IOException { ConfigureUnit[] fiter = null;/*from w w w.j a va 2 s . c o m*/ if (configCache == null) { configCache = buildConfig(); } if (filter == null) { Collection<ConfigureUnit> conf = configCache.values(); fiter = conf.toArray(new ConfigureUnit[] {}); } return fiter; }
From source file:com.phoenixst.collections.TransformerChain.java
/** * Creates a new <code>TransformerChain</code>. *///from w w w .jav a2 s . co m public TransformerChain(Collection transformers) { super(); Transformer[] temp = new Transformer[transformers.size()]; transformerArray = (Transformer[]) transformers.toArray(temp); if (containsNull(transformerArray)) { throw new IllegalArgumentException("Collection argument has a null element."); } }
From source file:com.fferreira.example.hazelcast.mapstore.postgres.HCPostgresWorkerTest.java
@Test(dependsOnGroups = COLD_START_GROUP) public void test_get_user_with_given_message_before_coldstart() throws InterruptedException { final Collection<User> users = worker.getUsersByFirstName(user.getFirtName()); assertEquals(users.size(), 1);/*from w ww.ja v a2s . c om*/ assertEquals(users.toArray(new User[users.size()])[0].getFirtName(), user.getFirtName()); }
From source file:org.juiser.spring.security.authentication.ClaimsGrantedAuthoritiesResolver.java
@Override public Collection<? extends GrantedAuthority> apply(Claims claims) { Collection<String> authorityStrings = authorityStringsResolver.apply(claims); if (CollectionUtils.isEmpty(authorityStrings)) { return Collections.emptyList(); }//from w w w .j ava 2s .c o m return AuthorityUtils.createAuthorityList(authorityStrings.toArray(new String[authorityStrings.size()])); }
From source file:mase.mason.world.DistanceSensorArcs.java
/** * Setting this makes the sensor ignore the object types, and use these * objects instead. Set null to ignore//www. j a va2 s. c om * * @param obj */ public void setObjects(Collection<? extends WorldObject> obj) { this.objects = obj.toArray(new WorldObject[obj.size()]); }
From source file:com.textocat.textokit.postagger.opennlp.OpenNLPPosTagger.java
private void process(JCas jCas, Sentence sent) throws AnalysisEngineProcessException { Collection<Token> tokens = JCasUtil.selectCovered(jCas, Token.class, sent); Token[] tokenArr = tokens.toArray(new Token[tokens.size()]); Sequence bestOutSeq = beam.bestSequence(tokenArr, new Object[] { sent }); if (bestOutSeq == null) { getLogger().warn(String.format("Can't infer best sequence for sentence in %s:\n%s", getDocumentUri(jCas), toPrettyString(sent))); return;//from ww w . ja v a 2 s. com } List<String> out = bestOutSeq.getOutcomes(); if (out.size() != tokens.size()) { throw new IllegalStateException("InputSeq.size != OutputSeq.size"); } Iterator<Token> tokenIter = tokens.iterator(); Iterator<String> outIter = out.iterator(); while (tokenIter.hasNext()) { Token token = tokenIter.next(); String tag = postProcessExternalTag(outIter.next()); if (isWordTag(token, tag)) { Word word = new Word(jCas, token.getBegin(), token.getEnd()); word.setToken(token); Wordform wf = new Wordform(jCas); wf.setWord(word); wf.setPos(tag); String[] gramArr = splitIntoGrammemes(tag); if (gramArr != null) { wf.setGrammems(FSUtils.toStringArray(jCas, gramArr)); } word.setWordforms(FSUtils.toFSArray(jCas, wf)); word.addToIndexes(); } } }
From source file:de.tobiasbruns.content.storage.ContentController.java
@RequestMapping(method = RequestMethod.GET, params = "projection=metadata", produces = "application/json") public @ResponseBody Resource<MetaDatum[]> loadMetadata(HttpServletRequest req, UriComponentsBuilder uriBuilder) { Link selfLink = new Link(uriBuilder.path(getPath(req)).queryParam("projection", "metadata").toUriString()); Collection<MetaDatum> metaData = service.loadMetaData(getPath(req)).getData(); return new Resource<>(metaData.toArray(new MetaDatum[metaData.size()]), selfLink); }
From source file:com.kylinolap.job.engine.JobEngine.java
private double[] getJobStepDuration() { Collection<Double> values = JOB_DURATION.values(); Double[] all = (Double[]) values.toArray(new Double[values.size()]); return ArrayUtils.toPrimitive(all); }
From source file:com.salesmanager.core.util.www.ajax.UpdateZones.java
@SuppressWarnings("unchecked") public Zone[] getZones(String countryId, int languageId) { int country = defaultcountryid; try {//from w w w.j av a 2 s .c om country = Integer.parseInt(countryId); } catch (Exception e) { log.error(e); } Collection<Zone> c = RefCache.getFilterdByCountryZones(country, languageId); if (c != null) { Zone[] z = new Zone[c.size()]; Zone[] znarray = (Zone[]) c.toArray(z); return znarray; } else { Zone[] z = new Zone[1]; Zone zone = new Zone(); zone.setZoneCountryId(country); zone.setZoneName("N/A"); zone.setZoneId(0); z[0] = zone; return z; } }