List of usage examples for java.util SortedMap values
Collection<V> values();
From source file:io.werval.modules.metrics.Tools.java
public Outcome healthchecks() throws JsonProcessingException { SortedMap<String, HealthCheck.Result> results = plugin(Metrics.class).healthChecks().runHealthChecks(); byte[] body = getJsonWriter().writeValueAsBytes(results); if (!results.values().stream().allMatch(r -> r.isHealthy())) { return outcomes().internalServerError().withBody(body).asJson().build(); }/*from w w w. j a v a 2 s. com*/ return outcomes().ok(body).asJson().build(); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.evaluation.F1ScoreTableAggregator.java
public static void evaluatePredictionsFoldersFullCV(File masterFolder) throws Exception { SortedMap<String, List<String>> featureSetsResults = new TreeMap<>(); File[] foldersFeatureSets = masterFolder.listFiles(EvalHelper.DIRECTORY_FILTER); for (File folderFeatureSet : foldersFeatureSets) { String[] split = folderFeatureSet.getName().split("_"); String featureSet = split[0]; String paramE = split[1]; String paramT = split[2]; if ("e0".equals(paramE) && "t1".equals(paramT)) { Map<String, File> foldersData = EvalHelper.listSubFoldersAndRemoveUUID(folderFeatureSet); for (Map.Entry<String, File> folderData : foldersData.entrySet()) { String data = folderData.getKey(); if (data.contains("ArgumentSequenceLabelingCV")) { File resultSummary = new File(folderData.getValue(), "resultSummary.txt"); List<String> values = extractValues(resultSummary); featureSetsResults.put(featureSet, values); }/*from w ww . j ava 2s . c om*/ } } } // print results int rows = featureSetsResults.values().iterator().next().size(); for (String featureSet : featureSetsResults.keySet()) { System.out.printf("%s\t", featureSet); } System.out.println(); for (int i = 0; i < rows; i++) { for (List<String> result : featureSetsResults.values()) { System.out.printf("%s\t", result.get(i)); } System.out.println(); } }
From source file:fr.pasteque.client.models.Catalog.java
public List<Product> getProductLikeBarcode(String barcode) { SortedMap<String, Product> sm = ((TreeMap<String, Product>) this.barcodeDb).subMap(barcode, barcode + Character.MAX_VALUE); return new ArrayList<Product>(sm.values()); }
From source file:com.adyen.Util.HMACValidator.java
public String getDataToSign(SortedMap<String, String> postParameters) { List<String> parts = new ArrayList<>(); for (String key : postParameters.keySet()) { parts.add(escapeVal(key));//from w ww. jav a 2 s . c om } for (String value : postParameters.values()) { parts.add(escapeVal(value)); } return Util.implode(DATA_SEPARATOR, parts); }
From source file:ca.tnt.ldaputils.impl.LdapOrganization.java
@SuppressWarnings({ "unchecked" }) @Override//from ww w . j a va 2s .c o m public List getValues(final Class classType, final Class refType, final Object instance) { final List<String> values = new ArrayList<String>(10); if (instance instanceof SortedMap) { // we know what to do final SortedMap<String, LdapGroup> groups = (SortedMap<String, LdapGroup>) instance; for (final ILdapGroup group : groups.values()) { values.add(group.getCN()); } } return values; }
From source file:cherry.goods.telno.TelNoNormalizerImpl.java
private List<Triple<Integer, Integer, Integer>> decompose(String telNo) { if (StringUtils.isEmpty(telNo)) { return null; } else if (telNo.startsWith("0120")) { // ??0120 // 0120-DEF-GHJ return asList(Triple.of(4, 3, 3)); } else if (telNo.startsWith("0800")) { // ??0800 // 0800-DEF-GHJK return asList(Triple.of(4, 3, 4)); } else if (telNo.startsWith("050")) { // IP??050 // 050-CDEF-GHJK return asList(Triple.of(3, 4, 4)); } else if (telNo.startsWith("070")) { // ?PHS??070 // 070-CDEF-GHJK return asList(Triple.of(3, 4, 4)); } else if (telNo.startsWith("080")) { // ?PHS??080 // 080-CDEF-GHJK return asList(Triple.of(3, 4, 4)); } else if (telNo.startsWith("090")) { // ?PHS??090 // 090-CDEF-GHJK return asList(Triple.of(3, 4, 4)); } else if (telNo.startsWith("020")) { // ??020//from w w w . j a v a 2s. c om // 020-CDEF-GHJK return asList(Triple.of(3, 4, 4)); } else if (telNo.startsWith("0570")) { // ??0570 // 0570-DEF-GHJ return asList(Triple.of(4, 3, 3)); } else if (telNo.startsWith("0990")) { // ???0990 // 0990-DE-FGHJ return asList(Triple.of(4, 2, 4)); } else { // ?? if (telNo.length() <= 2) { return null; } String prefix = (telNo.length() > 6 ? telNo.substring(0, 6) : telNo); SortedMap<String, Integer> map = areaCodeTable.prefixMap(prefix); if (map.isEmpty()) { return null; } Set<Integer> set = new TreeSet<>(map.values()); List<Triple<Integer, Integer, Integer>> list = new ArrayList<>(set.size()); for (Integer l : set) { list.add(Triple.of(l, 6 - l, 4)); } return list; } }
From source file:com.espertech.esper.schedule.SchedulingServiceImpl.java
public synchronized final void evaluate(Collection<ScheduleHandle> handles) { // Get the values on or before the current time - to get those that are exactly on the // current time we just add one to the current time for getting the head map SortedMap<Long, SortedMap<ScheduleSlot, ScheduleHandle>> headMap = timeHandleMap.headMap(currentTime + 1); if (headMap.isEmpty()) { return;/* w w w . ja v a 2 s .co m*/ } // First determine all triggers to shoot List<Long> removeKeys = new ArrayList<Long>(); for (Map.Entry<Long, SortedMap<ScheduleSlot, ScheduleHandle>> entry : headMap.entrySet()) { Long key = entry.getKey(); SortedMap<ScheduleSlot, ScheduleHandle> value = entry.getValue(); removeKeys.add(key); for (ScheduleHandle handle : value.values()) { handles.add(handle); } } // Next remove all handles for (Map.Entry<Long, SortedMap<ScheduleSlot, ScheduleHandle>> entry : headMap.entrySet()) { for (ScheduleHandle handle : entry.getValue().values()) { handleSetMap.remove(handle); } } // Remove all triggered msec values for (Long key : removeKeys) { timeHandleMap.remove(key); } }
From source file:com.dulion.astatium.mesh.shredder.ContextManager.java
@SuppressWarnings("unused") private void logNamesLike(String name) { SortedMap<String, List<QName>> prefixMap = nameTrie.prefixMap(name.toLowerCase()); prefixMap.values().stream().flatMap(nameList -> nameList.stream()).sorted((first, second) -> { int result = first.getLocalPart().compareTo(second.getLocalPart()); return 0 != result ? result : first.getNamespaceURI().compareTo(second.getNamespaceURI()); }).forEach(key -> LOG.info("Name: {}", key)); }
From source file:com.streamsets.pipeline.lib.jdbc.MultiRowInsertMap.java
public PreparedStatement getInsertFor(SortedMap<String, String> columns, int numRecords) throws SQLException { // The INSERT query we're going to perform (parameterized). if (cache.containsKey(columns)) { return cache.get(columns); } else {//from w w w. j a va 2 s .c o m String valuePlaceholder = String.format("(%s)", Joiner.on(", ").join(columns.values())); String valuePlaceholders = StringUtils.repeat(valuePlaceholder, ", ", numRecords); String query = String.format("INSERT INTO %s (%s) VALUES %s", tableName, // keySet and values will both return the same ordering, due to using a SortedMap Joiner.on(", ").join(columns.keySet()), valuePlaceholders); PreparedStatement statement = connection.prepareStatement(query); cache.put(columns, statement); return statement; } }
From source file:com.precioustech.fxtrading.tradingbot.strategies.FadeTheMoveStrategy.java
public void analysePrices() { for (Map.Entry<TradeableInstrument<T>, Cache<DateTime, MarketDataPayLoad<T>>> entry : instrumentRecentPricesCache .entrySet()) {/*from w ww . j a v a 2s. co m*/ SortedMap<DateTime, MarketDataPayLoad<T>> sortedByDate = ImmutableSortedMap .copyOf(entry.getValue().asMap()); if (sortedByDate.isEmpty()) { continue; } Double pipJump = calculatePipJump(sortedByDate.values(), entry.getKey()); Double absPipJump = Math.abs(pipJump); if (absPipJump >= this.pipJumpCutOffCalculator.calculatePipJumpCutOff(entry.getKey())) { MarketDataPayLoad<T> lastPayLoad = sortedByDate.get(sortedByDate.lastKey()); Double pip = this.instrumentService.getPipForInstrument(entry.getKey()); double takeProfitPrice; double limitPrice; TradingSignal signal = null; if (Math.signum(pipJump) > 0) {// Short signal = TradingSignal.SHORT; limitPrice = lastPayLoad.getBidPrice() + tradingConfig.getFadeTheMoveDistanceToTrade() * pip; takeProfitPrice = limitPrice - tradingConfig.getFadeTheMovePipsDesired() * pip; } else { signal = TradingSignal.LONG; limitPrice = lastPayLoad.getAskPrice() - tradingConfig.getFadeTheMoveDistanceToTrade() * pip; takeProfitPrice = limitPrice + tradingConfig.getFadeTheMovePipsDesired() * pip; } this.orderQueue.offer(new TradingDecision<T>(entry.getKey(), signal, takeProfitPrice, 0.0, limitPrice, TradingDecision.SRCDECISION.FADE_THE_MOVE)); entry.getValue().asMap().clear();/* * clear the prices so that we do not keep * working on old decision */ } } }