Java Code Examples for java.util.SortedSet
The following examples show how to use
java.util.SortedSet. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kylin-on-parquet-v2 Source File: KylinConfigBase.java License: Apache License 2.0 | 6 votes |
private static String getFileName(String homePath, Pattern pattern) { File home = new File(homePath); SortedSet<String> files = Sets.newTreeSet(); if (home.exists() && home.isDirectory()) { File[] listFiles = home.listFiles(); if (listFiles != null) { for (File file : listFiles) { final Matcher matcher = pattern.matcher(file.getName()); if (matcher.matches()) { files.add(file.getAbsolutePath()); } } } } if (files.isEmpty()) { throw new RuntimeException("cannot find " + pattern.toString() + " in " + homePath); } else { return files.last(); } }
Example 2
Source Project: phoenix-tephra Source File: InvalidListPruningDebugTool.java License: Apache License 2.0 | 6 votes |
/** * * @param timeString Given a time, provide the {@link TimeRegions} at or before that time. * Time can be in milliseconds or relative time. * @return transactional regions that are present at or before the given time * @throws IOException if there are any errors while trying to fetch the {@link TimeRegions} */ @Override @SuppressWarnings("WeakerAccess") public RegionsAtTime getRegionsOnOrBeforeTime(String timeString) throws IOException { long time = TimeMathParser.parseTime(timeString, TimeUnit.MILLISECONDS); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); TimeRegions timeRegions = dataJanitorState.getRegionsOnOrBeforeTime(time); if (timeRegions == null) { return new RegionsAtTime(time, new TreeSet<String>(), dateFormat); } SortedSet<String> regionNames = new TreeSet<>(); Iterable<String> regionStrings = Iterables.transform(timeRegions.getRegions(), TimeRegions.BYTE_ARR_TO_STRING_FN); for (String regionString : regionStrings) { regionNames.add(regionString); } return new RegionsAtTime(timeRegions.getTime(), regionNames, dateFormat); }
Example 3
Source Project: phoenix-tephra Source File: InvalidListPruningDebugTool.java License: Apache License 2.0 | 6 votes |
/** * * @param timeString Given a time, provide the {@link TimeRegions} at or before that time. * Time can be in milliseconds or relative time. * @return transactional regions that are present at or before the given time * @throws IOException if there are any errors while trying to fetch the {@link TimeRegions} */ @Override @SuppressWarnings("WeakerAccess") public RegionsAtTime getRegionsOnOrBeforeTime(String timeString) throws IOException { long time = TimeMathParser.parseTime(timeString, TimeUnit.MILLISECONDS); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); TimeRegions timeRegions = dataJanitorState.getRegionsOnOrBeforeTime(time); if (timeRegions == null) { return new RegionsAtTime(time, new TreeSet<String>(), dateFormat); } SortedSet<String> regionNames = new TreeSet<>(); Iterable<String> regionStrings = Iterables.transform(timeRegions.getRegions(), TimeRegions.BYTE_ARR_TO_STRING_FN); for (String regionString : regionStrings) { regionNames.add(regionString); } return new RegionsAtTime(timeRegions.getTime(), regionNames, dateFormat); }
Example 4
Source Project: j2objc Source File: TreeSubSetTest.java License: Apache License 2.0 | 6 votes |
/** * headSet returns set with keys in requested range */ public void testDescendingHeadSetContents() { NavigableSet set = dset5(); SortedSet sm = set.headSet(m4); assertTrue(sm.contains(m1)); assertTrue(sm.contains(m2)); assertTrue(sm.contains(m3)); assertFalse(sm.contains(m4)); assertFalse(sm.contains(m5)); Iterator i = sm.iterator(); Object k; k = (Integer)(i.next()); assertEquals(m1, k); k = (Integer)(i.next()); assertEquals(m2, k); k = (Integer)(i.next()); assertEquals(m3, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); assertEquals(2, set.size()); assertEquals(m4, set.first()); }
Example 5
Source Project: estatio Source File: OrderApprovalState_IntegTest.java License: Apache License 2.0 | 6 votes |
@Test public void complete_order_of_type_local_expenses_works_when_having_office_administrator_role_test() { // given Person personDaniel = (Person) partyRepository.findPartyByReference( Person_enum.DanielOfficeAdministratorFr.getRef()); SortedSet<PartyRole> rolesforDylan = personDaniel.getRoles(); assertThat(rolesforDylan.size()).isEqualTo(1); assertThat(rolesforDylan.first().getRoleType()).isEqualTo(partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.OFFICE_ADMINISTRATOR.getKey())); // when queryResultsCache.resetForNextTransaction(); // workaround: clear MeService#me cache setFixtureClockDate(2018,1, 6); sudoService.sudo(Person_enum.DanielOfficeAdministratorFr.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(Order_completeWithApproval.class, order)).act( personDaniel, new LocalDate(2018,1, 6), null)); assertThat(order.getApprovalState()).isEqualTo(OrderApprovalState.APPROVED); assertThat(taskRepository.findIncompleteByRole(partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.OFFICE_ADMINISTRATOR.getKey())).size()).isEqualTo(0); }
Example 6
Source Project: appinventor-extensions Source File: VersionStringTest.java License: Apache License 2.0 | 6 votes |
public void testSorting() throws Exception { SortedSet<VersionString> set = new TreeSet<VersionString>(); set.add(v3); set.add(v0); set.add(v1); set.add(v4); set.add(v2); assertEquals(v0, set.first()); assertTrue(set.remove(v0)); assertEquals(v1, set.first()); assertTrue(set.remove(v1)); assertEquals(v2, set.first()); assertTrue(set.remove(v2)); assertEquals(v3, set.first()); assertTrue(set.remove(v3)); assertEquals(v4, set.first()); assertTrue(set.remove(v4)); assertTrue(set.isEmpty()); }
Example 7
Source Project: fenixedu-academic Source File: AcademicServiceRequestsManagementDispatchAction.java License: GNU Lesser General Public License v3.0 | 6 votes |
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { final AcademicServiceRequestBean bean = getOrCreateAcademicServiceRequestBean(request); request.setAttribute("bean", bean); final Collection<AcademicServiceRequest> remainingRequests = bean.searchAcademicServiceRequests(); final Collection<AcademicServiceRequest> specificRequests = getAndRemoveSpecificRequests(bean, remainingRequests); final SortedSet<AcademicServiceRequest> sorted = new TreeSet<AcademicServiceRequest>(getComparator(request)); sorted.addAll(remainingRequests); request.setAttribute("remainingRequests", remainingRequests); request.setAttribute("specificRequests", specificRequests); final CollectionPager<AcademicServiceRequest> pager = new CollectionPager<AcademicServiceRequest>(sorted, REQUESTS_PER_PAGE); request.setAttribute("collectionPager", pager); request.setAttribute("numberOfPages", Integer.valueOf(pager.getNumberOfPages())); final String pageParameter = request.getParameter("pageNumber"); final Integer page = StringUtils.isEmpty(pageParameter) ? Integer.valueOf(1) : Integer.valueOf(pageParameter); request.setAttribute("pageNumber", page); request.setAttribute("resultPage", pager.getPage(page)); return mapping.findForward("searchResults"); }
Example 8
Source Project: james-project Source File: SimpleMessageSearchIndex.java License: Apache License 2.0 | 6 votes |
private List<SearchResult> searchResults(MailboxSession session, Mailbox mailbox, SearchQuery query) throws MailboxException { MessageMapper mapper = messageMapperFactory.getMessageMapper(session); final SortedSet<MailboxMessage> hitSet = new TreeSet<>(); UidCriterion uidCrit = findConjugatedUidCriterion(query.getCriteria()); if (uidCrit != null) { // if there is a conjugated uid range criterion in the query tree we can optimize by // only fetching this uid range UidRange[] ranges = uidCrit.getOperator().getRange(); for (UidRange r : ranges) { Iterator<MailboxMessage> it = mapper.findInMailbox(mailbox, MessageRange.range(r.getLowValue(), r.getHighValue()), FetchType.Metadata, UNLIMITED); while (it.hasNext()) { hitSet.add(it.next()); } } } else { // we have to fetch all messages Iterator<MailboxMessage> messages = mapper.findInMailbox(mailbox, MessageRange.all(), FetchType.Full, UNLIMITED); while (messages.hasNext()) { MailboxMessage m = messages.next(); hitSet.add(m); } } return ImmutableList.copyOf(new MessageSearches(hitSet.iterator(), query, textExtractor, attachmentContentLoader, session).iterator()); }
Example 9
Source Project: biojava Source File: RemotePDPProvider.java License: GNU Lesser General Public License v2.1 | 6 votes |
/** * Get a list of all PDP domains for a given PDB entry * @param pdbId PDB ID * @return Set of domain names, e.g. "PDP:4HHBAa" * @throws IOException if the server cannot be reached */ @Override public SortedSet<String> getPDPDomainNamesForPDB(String pdbId) throws IOException{ SortedSet<String> results = null; try { URL u = new URL(server + "getPDPDomainNamesForPDB?pdbId="+pdbId); logger.info("Fetching {}",u); InputStream response = URLConnectionTools.getInputStream(u); String xml = JFatCatClient.convertStreamToString(response); results = XMLUtil.getDomainRangesFromXML(xml); } catch (MalformedURLException e){ logger.error("Problem generating PDP request URL for "+pdbId,e); throw new IllegalArgumentException("Invalid PDB name: "+pdbId, e); } return results; }
Example 10
Source Project: ttt Source File: LineLayout.java License: BSD 2-Clause "Simplified" License | 6 votes |
private SortedSet<FontFeature> makeGlyphMappingFeatures(String script, String language, int bidiLevel, Axis axis, boolean kerned, Orientation orientation, Combination combination) { SortedSet<FontFeature> features = new java.util.TreeSet<FontFeature>(); if ((script != null) && !script.isEmpty()) features.add(FontFeature.SCPT.parameterize(script)); if ((language != null) && !language.isEmpty()) features.add(FontFeature.LANG.parameterize(language)); if (bidiLevel >= 0) features.add(FontFeature.BIDI.parameterize(bidiLevel)); if (kerned) features.add(FontFeature.KERN.parameterize(Boolean.TRUE)); else features.add(FontFeature.KERN.parameterize(Boolean.FALSE)); if ((orientation != null) && orientation.isRotated()) features.add(FontFeature.ORNT.parameterize(orientation)); if ((combination != null) && !combination.isNone()) features.add(FontFeature.COMB.parameterize(combination)); if ((axis != null) && axis.cross(!combination.isNone()).isVertical() && !orientation.isRotated()) features.add(FontFeature.VERT.parameterize(Boolean.TRUE)); return features; }
Example 11
Source Project: magarena Source File: MagicCombatCreature.java License: GNU General Public License v3.0 | 5 votes |
void setAttacker(final MagicGame game,final Set<MagicCombatCreature> blockers) { final SortedSet<MagicCombatCreature> candidateBlockersSet = new TreeSet<>(new BlockerComparator(this)); for (final MagicCombatCreature blocker : blockers) { if (blocker.permanent.canBlock(permanent)) { candidateBlockersSet.add(blocker); } } candidateBlockers=new MagicCombatCreature[candidateBlockersSet.size()]; candidateBlockersSet.toArray(candidateBlockers); attackerScore=ArtificialScoringSystem.getAttackerScore(this); }
Example 12
Source Project: audiveris Source File: TupletInter.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean checkAbnormal () { SortedSet<AbstractChordInter> embraced = TupletsBuilder.getEmbracedChords( this, getChords()); setAbnormal(embraced == null); return isAbnormal(); }
Example 13
Source Project: datawave Source File: IndexStatsQueryLogic.java License: Apache License 2.0 | 5 votes |
public SortedSet<Range> buildRanges(Collection<String> fields) { TreeSet<Range> ranges = new TreeSet<>(); for (String field : fields) { ranges.add(new Range(field, field + Constants.NULL_BYTE_STRING)); } return ranges; }
Example 14
Source Project: datawave Source File: MultiSetBackedSortedSet.java License: Apache License 2.0 | 5 votes |
@Override public boolean isEmpty() { for (SortedSet<E> set : sets) { if (!set.isEmpty()) { return false; } } return true; }
Example 15
Source Project: jdk8u-dev-jdk Source File: ResourceBundleGenerator.java License: GNU General Public License v2.0 | 5 votes |
@Override public void generateMetaInfo(Map<String, SortedSet<String>> metaInfo) throws IOException { String dirName = CLDRConverter.DESTINATION_DIR + File.separator + "sun" + File.separator + "util" + File.separator + "cldr" + File.separator; File dir = new File(dirName); if (!dir.exists()) { dir.mkdirs(); } File file = new File(dir, METAINFO_CLASS + ".java"); if (!file.exists()) { file.createNewFile(); } CLDRConverter.info("Generating file " + file); try (PrintWriter out = new PrintWriter(file, "us-ascii")) { out.println(CopyrightHeaders.getOpenJDKCopyright()); out.println("package sun.util.cldr;\n\n" + "import java.util.ListResourceBundle;\n"); out.printf("public class %s extends ListResourceBundle {\n", METAINFO_CLASS); out.println(" @Override\n" + " protected final Object[][] getContents() {\n" + " final Object[][] data = new Object[][] {"); for (String key : metaInfo.keySet()) { out.printf(" { \"%s\",\n", key); out.printf(" \"%s\" },\n", toLocaleList(metaInfo.get(key))); } out.println(" };\n return data;\n }\n}"); } }
Example 16
Source Project: vespa Source File: SearchChainResolverTestCase.java License: Apache License 2.0 | 5 votes |
@Test public void lists_source_ref_description_for_top_level_targets() { SortedSet<Target> topLevelTargets = searchChainResolver.allTopLevelTargets(); assertThat(topLevelTargets.size(), is(3)); Iterator<Target> i = topLevelTargets.iterator(); assertSearchRefDescriptionIs(i.next(), providerId.toString()); assertSearchRefDescriptionIs(i.next(), searchChainId.toString()); assertSearchRefDescriptionIs(i.next(), "source[provider = provider, provider2]"); }
Example 17
Source Project: alfresco-repository Source File: RepoServerMgmt.java License: GNU Lesser General Public License v3.0 | 5 votes |
public String[] listUserNamesNonExpired() { return useManagedResourceClassloader(new Work<String[]>() { @Override String[] doWork() { Set<String> userSet = authenticationService.getUsersWithTickets(true); SortedSet<String> sorted = new TreeSet<String>(userSet); return sorted.toArray(new String[0]); } }); }
Example 18
Source Project: onos Source File: OchSignalTest.java License: Apache License 2.0 | 5 votes |
@Test public void testToFlexgrid50() { OchSignal input = newDwdmSlot(CHL_50GHZ, 0); SortedSet<OchSignal> expected = newOchSignalTreeSet(); expected.addAll(ImmutableList.of( newFlexGridSlot(-3), newFlexGridSlot(-1), newFlexGridSlot(+1), newFlexGridSlot(+3))); SortedSet<OchSignal> flexGrid = OchSignal.toFlexGrid(input); assertEquals(expected, flexGrid); }
Example 19
Source Project: titus-control-plane Source File: JobRuntimePredictionsTest.java License: Apache License 2.0 | 5 votes |
@Test public void testOneLineRepresentation() { SortedSet<JobRuntimePrediction> predictions = new TreeSet<>(); predictions.add(new JobRuntimePrediction(0.95, 26.2)); predictions.add(new JobRuntimePrediction(0.1, 10.0)); predictions.add(new JobRuntimePrediction(0.2, 15.0)); JobRuntimePredictions jobRuntimePredictions = new JobRuntimePredictions("1", "some-id", predictions); Optional<String> asString = jobRuntimePredictions.toSimpleString(); assertThat(asString).isPresent(); assertThat(asString.get()).isEqualTo("0.1=10.0;0.2=15.0;0.95=26.2"); }
Example 20
Source Project: datawave Source File: FileSortedSet.java License: Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public boolean containsAll(Collection<?> c) { if (c.isEmpty()) { return true; } if (persisted) { try { SortedSet<E> all = new TreeSet<>(set.comparator()); for (Object o : c) { all.add((E) o); } try (SortedSetInputStream<E> stream = getBoundedFileHandler().getInputStream(getStart(), getEnd())) { E obj = stream.readObject(); while (obj != null) { if (all.remove(obj)) { if (all.isEmpty()) { return true; } } obj = stream.readObject(); } } } catch (Exception e) { throw new IllegalStateException("Unable to read file into a complete set", e); } return false; } else { return set.containsAll(c); } }
Example 21
Source Project: lombok-intellij-plugin Source File: SingularSortedSet2.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") SingularSortedSet2(final SortedSet rawTypes, final SortedSet<Integer> integers, final SortedSet<T> generics, final SortedSet<? extends Number> extendsGenerics) { this.rawTypes = rawTypes; this.integers = integers; this.generics = generics; this.extendsGenerics = extendsGenerics; }
Example 22
Source Project: act Source File: HMDBParser.java License: GNU General Public License v3.0 | 5 votes |
protected SortedSet<File> findHMDBFilesInDirectory(File dir) throws IOException { // Sort for consistency + sanity. SortedSet<File> results = new TreeSet<>((a, b) -> a.getName().compareTo(b.getName())); for (File file : dir.listFiles()) { // Do our own filtering so we can log rejects, of which we expect very few. if (HMDB_FILE_REGEX.matcher(file.getName()).matches()) { results.add(file); } else { LOGGER.warn("Found non-conforming HMDB file in directory %s: %s", dir.getAbsolutePath(), file.getName()); } } return results; }
Example 23
Source Project: heroic Source File: FilterUtils.java License: Apache License 2.0 | 5 votes |
public static boolean containsPrefixedWith( final SortedSet<Filter> statements, final StartsWithFilter outer, final BiFunction<StartsWithFilter, StartsWithFilter, Boolean> check ) { return statements .stream() .filter(inner -> inner instanceof StartsWithFilter) .map(StartsWithFilter.class::cast) .filter(statements::contains) .filter(inner -> outer.tag().equals(inner.tag())) .filter(inner -> check.apply(inner, outer)) .findFirst() .isPresent(); }
Example 24
Source Project: datawave Source File: BufferedFileBackedSortedSet.java License: Apache License 2.0 | 5 votes |
public BufferedFileBackedSortedSet(BufferedFileBackedSortedSet<E> other) { this(other.comparator, other.bufferPersistThreshold, other.maxOpenFiles, other.numRetries, new ArrayList<>(other.handlerFactories), other.setFactory); for (SortedSet<E> subSet : other.set.getSets()) { FileSortedSet<E> clone = ((FileSortedSet<E>) subSet).clone(); this.set.addSet(clone); if (!clone.isPersisted()) { this.buffer = clone; } } this.sizeModified = other.sizeModified; this.size = other.size; }
Example 25
Source Project: codebuff Source File: Multimaps.java License: BSD 2-Clause "Simplified" License | 5 votes |
@GwtIncompatible // java.io.ObjectInputStream @SuppressWarnings("unchecked") // reading data stored by writeObject private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); factory = (Supplier<? extends SortedSet<V>>) stream.readObject(); valueComparator = factory.get().comparator(); Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject(); setMap(map); }
Example 26
Source Project: mybaties Source File: CustomObjectFactory.java License: Apache License 2.0 | 5 votes |
private Class<?> resolveInterface(Class<?> type) { Class<?> classToCreate; if (type == List.class || type == Collection.class) { classToCreate = LinkedList.class; } else if (type == Map.class) { classToCreate = LinkedHashMap.class; } else if (type == SortedSet.class) { // issue #510 Collections Support classToCreate = TreeSet.class; } else if (type == Set.class) { classToCreate = HashSet.class; } else { classToCreate = type; } return classToCreate; }
Example 27
Source Project: codebuff Source File: Sets.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override public E last() { SortedSet<E> sortedUnfiltered = (SortedSet<E>) unfiltered; while (true) { E element = sortedUnfiltered.last(); if (predicate.apply(element)) { return element; } sortedUnfiltered = sortedUnfiltered.headSet(element); } }
Example 28
Source Project: lams Source File: ComplexActivity.java License: GNU General Public License v2.0 | 5 votes |
/** * Get all the tool activities in this activity. Called by Activity.getAllToolActivities(). Recursively get tool * activity from its children. */ @Override protected void getToolActivitiesInActivity(SortedSet<ToolActivity> toolActivities) { for (Iterator<Activity> i = this.getActivities().iterator(); i.hasNext();) { Activity child = i.next(); child.getToolActivitiesInActivity(toolActivities); } }
Example 29
Source Project: backstopper Source File: ProjectApiErrorsTestBase.java License: Apache License 2.0 | 5 votes |
@Test public void shouldNotContainDuplicateNamedApiErrors() { Map<String, Integer> nameToCountMap = new HashMap<>(); SortedSet<String> duplicateErrorNames = new TreeSet<>(); for (ApiError apiError : getProjectApiErrors().getProjectApiErrors()) { Integer currentCount = nameToCountMap.get(apiError.getName()); if (currentCount == null) currentCount = 0; Integer newCount = currentCount + 1; nameToCountMap.put(apiError.getName(), newCount); if (newCount > 1) duplicateErrorNames.add(apiError.getName()); } if (!duplicateErrorNames.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("There are ApiError instances in the ProjectApiErrors that share duplicate names. [name, count]: "); boolean first = true; for (String dup : duplicateErrorNames) { if (!first) sb.append(", "); sb.append("[").append(dup).append(", ").append(nameToCountMap.get(dup)).append("]"); first = false; } throw new AssertionError(sb.toString()); } }
Example 30
Source Project: steady Source File: WSS4JInOutTest.java License: Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }