List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:com.sun.labs.aura.fb.DataManager.java
/** * Get the URL for a thumbnail of the provided artist. * //from w ww. jav a2s .c o m * @param a the artist * @return a thumbnail URL or null if we couldn't get one * @throws com.sun.labs.aura.util.AuraException */ public String getThumbnailImageURL(Artist a) throws AuraException { String url = null; if (url == null) { Set<String> photoIDs = a.getPhotos(); if (photoIDs.size() > 0) { String[] ids = photoIDs.toArray(new String[photoIDs.size()]); url = Photo.idToThumbnail(ids[0]); } } if (url == null) { Set<String> albumIDs = a.getAlbums(); if (albumIDs.size() > 0) { String[] ids = albumIDs.toArray(new String[albumIDs.size()]); Album album = mdb.albumLookup(ids[0]); url = album.getAlbumArt(); } } return url; }
From source file:jp.co.nemuzuka.dao.MemberDao.java
/** * List?.//from w w w.ja va 2 s .com * @param name ???(?) * @param mail (?) * @return */ public List<MemberModel> getList(String name, String mail) { MemberModelMeta e = (MemberModelMeta) getModelMeta(); Set<FilterCriterion> filterSet = new HashSet<FilterCriterion>(); if (StringUtils.isNotEmpty(name)) { filterSet.add(e.name.startsWith(name)); } if (StringUtils.isNotEmpty(mail)) { filterSet.add(e.mail.startsWith(mail)); } return Datastore.query(e).filter(filterSet.toArray(new FilterCriterion[0])) .sortInMemory(e.authority.asc, e.key.asc).asList(); }
From source file:org.grails.datastore.mapping.redis.RedisSession.java
@Override protected void postFlush(boolean hasUpdates) { if (!hasUpdates) { return;//from w w w .j a va2 s .co m } final Set<String> keys = redisTemplate.keys("~*"); if (keys != null && !keys.isEmpty()) { redisTemplate.del(keys.toArray(new String[keys.size()])); } }
From source file:com.taobao.metamorphosis.client.producer.SimpleXAMessageProducer.java
private void generateTransactionBrokerURLs() { final List<Set<String>> brokerUrls = new ArrayList<Set<String>>(); for (final String topic : this.publishedTopics) { brokerUrls.add(this.producerZooKeeper.getServerUrlSetByTopic(topic)); // Listen for brokers changing. this.producerZooKeeper.onBrokerChange(topic, this); }/* w w w .j av a 2 s . co m*/ final Set<String> resultSet = intersect(brokerUrls); if (resultSet.isEmpty()) { throw new InvalidBrokerException( "Could not select a common broker url for topics:" + this.publishedTopics); } String[] newUrls = resultSet.toArray(new String[resultSet.size()]); Arrays.sort(newUrls); // Set new urls array. this.urls = newUrls; }
From source file:eu.itesla_project.online.tools.RunTDSimulation.java
private void writeCsvTDResults(Path folder, Map<String, Map<String, Boolean>> tdSimulationsResults) throws IOException { Path csvFile = getFile(folder, "simulation-results.csv"); System.out.println("writing simulation results to file " + csvFile.toString()); Set<String> securityIndexIds = new LinkedHashSet<>(); tdSimulationsResults.values().stream().filter(m -> m != null) .forEach(m -> securityIndexIds.addAll(m.keySet())); String[] indexIds = securityIndexIds.toArray(new String[securityIndexIds.size()]); Arrays.sort(indexIds);//from w w w .j ava2 s . c om try (FileWriter content = new FileWriter(csvFile.toFile())) { CsvWriter cvsWriter = null; try { cvsWriter = new CsvWriter(content, ','); String[] headers = new String[indexIds.length + 1]; headers[0] = "Basecase"; int i = 1; for (String securityIndexId : indexIds) headers[i++] = securityIndexId; cvsWriter.writeRecord(headers); for (String caseBasename : tdSimulationsResults.keySet()) { String[] values = new String[indexIds.length + 1]; values[0] = caseBasename; i = 1; for (String securityIndexId : indexIds) { String result = "NA"; if (tdSimulationsResults.get(caseBasename).containsKey(securityIndexId)) result = tdSimulationsResults.get(caseBasename).get(securityIndexId) ? "OK" : "KO"; values[i++] = result; } cvsWriter.writeRecord(values); } cvsWriter.flush(); } finally { if (cvsWriter != null) cvsWriter.close(); } } }
From source file:com.microsoft.tfs.core.clients.workitem.internal.fields.AllowedValuesHelper.java
private String[] computeNodeNames(final NodeMetadata[] nodeMetadataArray) { final Set<String> names = new HashSet<String>(); for (int i = 0; i < nodeMetadataArray.length; i++) { names.add(nodeMetadataArray[i].getName()); }//from w ww . jav a 2 s . c o m return names.toArray(new String[names.size()]); }
From source file:com.google.dart.engine.services.internal.correction.CorrectionUtils.java
/** * @return the possible names for variable with initializer of the given {@link StringLiteral}. */// www .j av a 2s . co m public static String[] getVariableNameSuggestions(String text, Set<String> excluded) { // filter out everything except of letters and white spaces { CharMatcher matcher = CharMatcher.JAVA_LETTER.or(CharMatcher.WHITESPACE); text = matcher.retainFrom(text); } // make single camel-case text { String[] words = StringUtils.split(text); StringBuilder sb = new StringBuilder(); for (int i = 0; i < words.length; i++) { String word = words[i]; if (i > 0) { word = StringUtils.capitalize(word); } sb.append(word); } text = sb.toString(); } // split camel-case into separate suggested names Set<String> res = Sets.newLinkedHashSet(); addAll(excluded, res, getVariableNameSuggestions(text)); return res.toArray(new String[res.size()]); }
From source file:de.tuberlin.uebb.jdae.llmsl.Block.java
public Block(double[][] data, DataLayout layout, Set<GlobalVariable> variables, Set<DerivedEquation> equations, SimulationOptions options) {//from w ww . ja va 2 s .co m this.options = options; this.variables = variables.toArray(new GlobalVariable[variables.size()]); Arrays.sort(this.variables, Ordering.natural()); this.view = new ExecutionContext(0, this.variables, data); final Map<Integer, Integer> gvIndex = Maps.newTreeMap(); for (int i = 0; i < this.variables.length; i++) { if (!gvIndex.containsKey(this.variables[i].index)) gvIndex.put(this.variables[i].index, i); } final Map<GlobalVariable, BlockVariable> blockVars = makeBlockVars(layout, equations, gvIndex); this.views = new ExecutionContext[equations.size()]; this.equations = new Residual[equations.size()]; this.residuals = new TDNumber[equations.size()]; int index = 0; for (DerivedEquation e : equations) { this.equations[index] = new Residual(e.eqn.bind(blockVars), e.minOrder, e.maxOrder); views[index++] = view.derived(e.maxOrder); } jacobianMatrix = new DenseMatrix64F(this.variables.length, this.variables.length); residual = new DenseMatrix64F(this.variables.length, 1); x = new DenseMatrix64F(this.variables.length); solver = LinearSolverFactory.linear(this.variables.length); this.point = new double[this.variables.length]; }
From source file:hoot.services.controllers.osm.OSMTestUtils.java
static Set<Long> createTestRelations(long changesetId, Set<Long> nodeIds, Set<Long> wayIds) throws Exception { Long[] nodeIdsArr = nodeIds.toArray(new Long[nodeIds.size()]); Long[] wayIdsArr = wayIds.toArray(new Long[wayIds.size()]); List<RelationMember> members = new ArrayList<>(); members.add(new RelationMember(nodeIdsArr[0], ElementType.Node, "role1")); members.add(new RelationMember(wayIdsArr[1], ElementType.Way, "role3")); members.add(new RelationMember(wayIdsArr[0], ElementType.Way, "role2")); members.add(new RelationMember(nodeIdsArr[2], ElementType.Node)); Map<String, String> tags = new HashMap<>(); tags.put("key 1", "val 1"); long firstRelationId = insertNewRelation(changesetId, getMapId(), members, tags); Set<Long> relationIds = new LinkedHashSet<>(); relationIds.add(firstRelationId);/* ww w .j av a 2s . c o m*/ tags.clear(); members.clear(); tags.put("key 2", "val 2"); tags.put("key 3", "val 3"); members.add(new RelationMember(nodeIdsArr[4], ElementType.Node, "role1")); members.add(new RelationMember(firstRelationId, ElementType.Relation, "role1")); relationIds.add(insertNewRelation(changesetId, getMapId(), members, tags)); tags.clear(); members.clear(); tags.put("key 4", "val 4"); members.add(new RelationMember(wayIdsArr[1], ElementType.Way)); relationIds.add(insertNewRelation(changesetId, getMapId(), members, tags)); tags.clear(); members.clear(); members.add(new RelationMember(nodeIdsArr[2], ElementType.Node, "role1")); relationIds.add(insertNewRelation(changesetId, getMapId(), members, null)); members.clear(); return relationIds; }
From source file:springfox.documentation.spring.data.rest.EntitySchemaHandler.java
@Override public PatternsRequestCondition getPatternsCondition() { Set<String> patterns = newHashSet(); for (String each : requestMapping.getPatternsCondition().getPatterns()) { String replaced = each.replace("/{repository}", resource.getPath().toString()); patterns.add(replaced);//from w ww. j a v a2 s. c om } return new PatternsRequestCondition(patterns.toArray(new String[patterns.size()])); }