java.util.SortedSet Java Examples

The following examples show how to use java.util.SortedSet. 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 File: TreeSubSetTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #2
Source File: RemotePDPProvider.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #3
Source File: LineLayout.java    From ttt with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: KylinConfigBase.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: SimpleMessageSearchIndex.java    From james-project with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: InvalidListPruningDebugTool.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @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 #7
Source File: InvalidListPruningDebugTool.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @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 #8
Source File: AcademicServiceRequestsManagementDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #9
Source File: VersionStringTest.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: OrderApprovalState_IntegTest.java    From estatio with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: ComplexActivity.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
    * 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 #12
Source File: ProjectApiErrorsTestBase.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@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 #13
Source File: AttributionPresenter.java    From AttributionPresenter with Apache License 2.0 5 votes vote down vote up
private AttributionPresenter(Context context,
                             SortedSet<Attribution> attributions,
                             @LayoutRes int itemLayout,
                             @LayoutRes int licenseLayout,
                             @Nullable OnAttributionClickListener onAttributionClickListener,
                             @Nullable OnLicenseClickListener onLicenseClickListener) {
    this.context = context;
    this.attributions = attributions;
    this.itemLayout = itemLayout == 0 ? R.layout.default_item_attribution : itemLayout;
    this.licenseLayout = licenseLayout == 0 ? R.layout.default_license_text : licenseLayout;
    this.onAttributionClickListener = onAttributionClickListener;
    this.onLicenseClickListener = onLicenseClickListener;
}
 
Example #14
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@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"));
}
 
Example #15
Source File: UnicodeSetTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
void checkSetRelation(SortedSet a, SortedSet b, String message) {
    for (int i = 0; i < 8; ++i) {

        boolean hasRelation = SortedSetRelation.hasRelation(a, i, b);
        boolean dumbHasRelation = dumbHasRelation(a, i, b);

        logln(message + " " + hasRelation + ":\t" + a + "\t" + RELATION_NAME[i] + "\t" + b);

        if (hasRelation != dumbHasRelation) {
            errln("FAIL: " + 
                    message + " " + dumbHasRelation + ":\t" + a + "\t" + RELATION_NAME[i] + "\t" + b);
        }
    }
    logln("");
}
 
Example #16
Source File: DbOperationManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void addSortedModificationsForType(Class<?> type, SortedSet<DbEntityOperation> preSortedOperations, List<DbOperation> flush) {
  if(preSortedOperations != null) {
    if(HasDbReferences.class.isAssignableFrom(type)) {
      // if this type has self references, we need to resolve the reference order
      flush.addAll(sortByReferences(preSortedOperations));
    } else {
      flush.addAll(preSortedOperations);
    }
  }
}
 
Example #17
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SortedSet<YearMonthDay> getAllLessonDatesWithoutInstanceDates() {
    SortedSet<YearMonthDay> dates = new TreeSet<YearMonthDay>();
    if (!wasFinished()) {
        YearMonthDay startDateToSearch = getLessonStartDay();
        YearMonthDay endDateToSearch = getLessonEndDay();
        dates.addAll(getAllValidLessonDatesWithoutInstancesDates(startDateToSearch, endDateToSearch));
    }
    return dates;
}
 
Example #18
Source File: JavaTestDescriptionTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void rulesExportedFromProvidedDepsBecomeFirstOrderDeps() {
  TargetNode<?> exportedNode =
      JavaLibraryBuilder.createBuilder(
              BuildTargetFactory.newInstance("//:exported_rule"), javaBuckConfig)
          .addSrc(Paths.get("java/src/com/exported_rule/foo.java"))
          .build();
  TargetNode<?> exportingNode =
      JavaLibraryBuilder.createBuilder(
              BuildTargetFactory.newInstance("//:exporting_rule"), javaBuckConfig)
          .addSrc(Paths.get("java/src/com/exporting_rule/bar.java"))
          .addExportedDep(exportedNode.getBuildTarget())
          .build();
  TargetNode<?> javaTestNode =
      JavaTestBuilder.createBuilder(BuildTargetFactory.newInstance("//:rule"), javaBuckConfig)
          .addProvidedDep(exportingNode.getBuildTarget())
          .build();

  TargetGraph targetGraph =
      TargetGraphFactory.newInstance(exportedNode, exportingNode, javaTestNode);

  ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph);

  JavaTest javaTest = (JavaTest) graphBuilder.requireRule(javaTestNode.getBuildTarget());
  BuildRule exportedRule = graphBuilder.requireRule(exportedNode.getBuildTarget());

  // First order deps should become CalculateAbi rules if we're compiling against ABIs
  if (compileAgainstAbis.equals(TRUE)) {
    exportedRule = graphBuilder.getRule(((JavaLibrary) exportedRule).getAbiJar().get());
  }

  SortedSet<BuildRule> deps = javaTest.getCompiledTestsLibrary().getBuildDeps();
  assertThat(deps, Matchers.hasItem(exportedRule));
}
 
Example #19
Source File: DegreeChangeCandidacyProcess.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addCandidacy(final Map<Degree, SortedSet<DegreeChangeIndividualCandidacyProcess>> result,
        final DegreeChangeIndividualCandidacyProcess process) {
    SortedSet<DegreeChangeIndividualCandidacyProcess> values = result.get(process.getCandidacySelectedDegree());
    if (values == null) {
        result.put(process.getCandidacySelectedDegree(), values =
                new TreeSet<DegreeChangeIndividualCandidacyProcess>(
                        DegreeChangeIndividualCandidacyProcess.COMPARATOR_BY_CANDIDACY_PERSON));
    }
    values.add(process);
}
 
Example #20
Source File: LeaderElection.java    From Scribengin with GNU Affero General Public License v3.0 5 votes vote down vote up
private SortedSet<LeaderId> getSortedLockIds() throws RegistryException {
  List<String> names = registry.getChildren(electionPath) ;
  SortedSet<LeaderId> sortedLockIds = new TreeSet<LeaderId>();
  for (String nodeName : names) {
    if(nodeName.startsWith("leader-")) {
      sortedLockIds.add(new LeaderId(electionPath + "/" + nodeName));
    }
  }
  return sortedLockIds;
}
 
Example #21
Source File: NamespaceIsolationPolicyImpl.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public SortedSet<BrokerStatus> getAvailablePrimaryBrokers(SortedSet<BrokerStatus> primaryCandidates) {
    SortedSet<BrokerStatus> availablePrimaries = new TreeSet<BrokerStatus>();
    for (BrokerStatus status : primaryCandidates) {
        if (this.autoFailoverPolicy.isBrokerAvailable(status)) {
            availablePrimaries.add(status);
        }
    }
    return availablePrimaries;
}
 
Example #22
Source File: Sets.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #23
Source File: MonitoringController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void statistic(HttpServletRequest request, Long contentID) {
SortedSet<StatisticDTO> statistics = new TreeSet<>(new StatisticComparator());
SubmitFilesContent spreadsheet = submitFilesService.getSubmitFilesContent(contentID);
if (spreadsheet.isUseSelectLeaderToolOuput()) {
    statistics.addAll(submitFilesService.getLeaderStatisticsBySession(contentID));
    request.setAttribute("statisticList", statistics);
} else {
    statistics.addAll(submitFilesService.getStatisticsBySession(contentID));
    request.setAttribute("statisticList", statistics);
}
   }
 
Example #24
Source File: TupletInter.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean checkAbnormal ()
{
    SortedSet<AbstractChordInter> embraced = TupletsBuilder.getEmbracedChords(
            this,
            getChords());
    setAbnormal(embraced == null);

    return isAbnormal();
}
 
Example #25
Source File: CustomObjectFactory.java    From mybaties with Apache License 2.0 5 votes vote down vote up
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 #26
Source File: Multimaps.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #27
Source File: BufferedFileBackedSortedSet.java    From datawave with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: FilterUtils.java    From heroic with Apache License 2.0 5 votes vote down vote up
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 #29
Source File: HMDBParser.java    From act with GNU General Public License v3.0 5 votes vote down vote up
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 #30
Source File: MemoryDataStoreOperations.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(final GeoWaveRow row) {
  final MemoryStoreEntry entry = new MemoryStoreEntry(row);
  if (isAuthorized(entry, authorizations)) {
    final SortedSet<MemoryStoreEntry> rowTreeSet = storeData.get(indexName);
    if (rowTreeSet != null) {
      if (!rowTreeSet.remove(entry)) {
        LOGGER.warn("Unable to remove entry");
      }
    }
  }
}