Example usage for java.util TreeSet isEmpty

List of usage examples for java.util TreeSet isEmpty

Introduction

In this page you can find the example usage for java.util TreeSet isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.thoughtworks.go.server.dao.PipelineSqlMapDao.java

private void removeCurrentLatestIfNoLongerActive(Stage stage, TreeSet<Long> ids) {
    if (!ids.isEmpty()) {
        if (isNewerThanCurrentLatest(stage, ids) && isCurrentLatestInactive(ids)) {
            ids.remove(ids.last());/*from  ww w. jav a2s. c o  m*/
        }
    }
}

From source file:net.spfbl.core.Analise.java

private static boolean hasReverse(String ip) {
    try {/*w  ww. j a va2  s.c  om*/
        TreeSet<String> reverseSet = Reverse.getPointerSet(ip);
        if (reverseSet == null) {
            return false;
        } else {
            return !reverseSet.isEmpty();
        }
    } catch (NamingException ex) {
        return false;
    }
}

From source file:biz.netcentric.cq.tools.actool.dumpservice.impl.DumpserviceImpl.java

private void createTransientDumpNode(String dump, Node rootNode)
        throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException,
        VersionException, ConstraintViolationException, RepositoryException, ValueFormatException {

    NodeIterator nodeIt = rootNode.getNodes();

    // TreeSet used here since only this type offers the methods first() and
    // last()//from   w w  w  .j ava  2 s .com
    TreeSet<Node> dumpNodes = new TreeSet<Node>(new JcrCreatedComparator());

    Node previousDumpNode = null;

    // get all dump nodes
    while (nodeIt.hasNext()) {
        Node currNode = nodeIt.nextNode();

        if (currNode.getName().startsWith(DUMP_NODE_PREFIX)) {
            dumpNodes.add(currNode);
        }
    }
    // try to get previous dump node
    if (!dumpNodes.isEmpty()) {
        previousDumpNode = dumpNodes.first();
    }
    // is limit of dump nodes to save reached?
    if (dumpNodes.size() > (nrOfSavedDumps - 1)) {
        Node oldestDumpNode = dumpNodes.last();
        oldestDumpNode.remove();
    }
    Node dumpNode = getNewDumpNode(dump, rootNode);

    // order the newest dump node as first child node of ac root node
    if (previousDumpNode != null) {
        rootNode.orderBefore(dumpNode.getName(), previousDumpNode.getName());
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.coordinator.thesis.ManageThesisDA.java

private ExecutionYear getExecutionYear(HttpServletRequest request) {
    String id = request.getParameter("executionYearId");
    if (id == null) {
        id = request.getParameter("executionYear");
    }/*from ww  w.  j a va  2  s . c o m*/
    if (id == null) {
        TreeSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(new ReverseComparator());
        executionYears.addAll(getDegreeCurricularPlan(request).getExecutionYears());

        if (executionYears.isEmpty()) {
            return ExecutionYear.readCurrentExecutionYear();
        } else {
            return executionYears.first();
        }
    } else {
        return FenixFramework.getDomainObject(id);
    }
}

From source file:net.sourceforge.fenixedu.domain.degree.DegreeType.java

public CycleType getFirstOrderedCycleType() {
    final TreeSet<CycleType> ordered = getOrderedCycleTypes();
    return ordered.isEmpty() ? null : ordered.first();
}

From source file:net.sourceforge.fenixedu.domain.degree.DegreeType.java

public CycleType getLastOrderedCycleType() {
    final TreeSet<CycleType> ordered = getOrderedCycleTypes();
    return ordered.isEmpty() ? null : ordered.last();
}

From source file:org.geoserver.security.iride.IrideRoleService.java

@Override
public SortedSet<GeoServerRole> getRolesForUser(final String username) throws IOException {
    LOGGER.trace("User: {}", username);

    final TreeSet<GeoServerRole> roles = new TreeSet<>();

    final IrideIdentity irideIdentity = IrideIdentity.parseIrideIdentity(username);
    if (irideIdentity != null) {
        final IrideRole[] irideRoles = this.getIrideService().findRuoliForPersonaInApplication(irideIdentity,
                new IrideApplication(this.config.applicationName));
        for (final IrideRole irideRole : irideRoles) {
            roles.add(this.createRoleObject(irideRole.toMnemonicRepresentation()));
        }// ww w . j  a v  a2s. c o  m
    }

    // Rely on the fallback RoleService (if configured) when no IRIDE roles are available for the given user
    if (roles.isEmpty() && this.config.hasFallbackRoleServiceName()) {
        LOGGER.info("No IRIDE roles available for the given user {}: falling back to RoleService '{}'",
                username, this.config.fallbackRoleServiceName);

        final GeoServerRoleService fallbackRoleService = this.getSecurityManager()
                .loadRoleService(this.config.fallbackRoleServiceName);
        if (fallbackRoleService != null) {
            roles.addAll(fallbackRoleService.getRolesForUser(username));
        } else {
            LOGGER.warn("A fallback RoleService '{}' was specified, but none was found!",
                    this.config.fallbackRoleServiceName);
        }
    }

    LOGGER.trace("Added {} roles for User {}", roles.size(), username);

    return ImmutableSortedSet.copyOf(roles);
}

From source file:org.apache.hadoop.hbase.backup.impl.RestoreTablesClient.java

/**
 * Restore operation. Stage 2: resolved Backup Image dependency
 * @param backupManifestMap : tableName, Manifest
 * @param sTableArray The array of tables to be restored
 * @param tTableArray The array of mapping tables to restore to
 * @throws IOException exception/*from  w w  w. java  2 s .  co  m*/
 */
private void restore(HashMap<TableName, BackupManifest> backupManifestMap, TableName[] sTableArray,
        TableName[] tTableArray, boolean isOverwrite) throws IOException {
    TreeSet<BackupImage> restoreImageSet = new TreeSet<>();

    for (int i = 0; i < sTableArray.length; i++) {
        TableName table = sTableArray[i];

        BackupManifest manifest = backupManifestMap.get(table);
        // Get the image list of this backup for restore in time order from old
        // to new.
        List<BackupImage> list = new ArrayList<>();
        list.add(manifest.getBackupImage());
        TreeSet<BackupImage> set = new TreeSet<>(list);
        List<BackupImage> depList = manifest.getDependentListByTable(table);
        set.addAll(depList);
        BackupImage[] arr = new BackupImage[set.size()];
        set.toArray(arr);
        restoreImages(arr, table, tTableArray[i], isOverwrite);
        restoreImageSet.addAll(list);
        if (restoreImageSet != null && !restoreImageSet.isEmpty()) {
            LOG.info("Restore includes the following image(s):");
            for (BackupImage image : restoreImageSet) {
                LOG.info("Backup: " + image.getBackupId() + " "
                        + HBackupFileSystem.getTableBackupDir(image.getRootDir(), image.getBackupId(), table));
            }
        }
    }
    LOG.debug("restoreStage finished");
}

From source file:org.lockss.devtools.CrawlRuleTester.java

private void checkRules() {
    outputMessage("\nChecking " + m_baseUrl, TEST_SUMMARY_MESSAGE);
    outputMessage("crawl depth: " + m_crawlDepth + "     crawl delay: " + m_crawlDelay + " ms.", PLAIN_MESSAGE);

    TreeSet crawlList = new TreeSet();
    TreeSet fetched = new TreeSet();
    // inialize with the baseUrl
    crawlList.add(m_baseUrl);/*from w w w .ja v  a2s .  c  o  m*/
    depth_incl = new int[m_crawlDepth];
    depth_fetched = new int[m_crawlDepth];
    depth_parsed = new int[m_crawlDepth];
    long start_time = TimeBase.nowMs();
    for (int depth = 1; depth <= m_crawlDepth; depth++) {
        if (isInterrupted()) {
            return;
        }
        m_curDepth = depth;
        if (crawlList.isEmpty() && depth <= m_crawlDepth) {
            outputMessage("\nNothing left to crawl, exiting after depth " + (depth - 1), PLAIN_MESSAGE);
            break;
        }
        String[] urls = (String[]) crawlList.toArray(new String[0]);
        crawlList.clear();
        outputMessage("\nDepth " + depth, PLAIN_MESSAGE);
        for (int ix = 0; ix < urls.length; ix++) {
            if (isInterrupted()) {
                return;
            }
            pauseBeforeFetch();
            String urlstr = urls[ix];

            m_incls.clear();
            m_excls.clear();

            // crawl the page
            buildUrlSets(urlstr);
            fetched.add(urlstr);
            // output incl/excl results,
            // add the new_incls to the crawlList for next crawl depth loop
            crawlList.addAll(outputUrlResults(urlstr, m_incls, m_excls));
        }
    }
    long elapsed_time = TimeBase.nowMs() - start_time;
    outputSummary(m_baseUrl, fetched, crawlList, elapsed_time);
}

From source file:ca.uhn.fhir.jpa.dao.dstu3.SearchParamExtractorDstu3.java

@Override
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity,
        IBaseResource theResource) {//  www  .  j  av  a2s. c  om
    HashSet<ResourceIndexedSearchParamDate> retVal = new HashSet<ResourceIndexedSearchParamDate>();

    RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
    for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
        if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.DATE) {
            continue;
        }

        String nextPath = nextSpDef.getPath();
        if (isBlank(nextPath)) {
            continue;
        }

        boolean multiType = false;
        if (nextPath.endsWith("[x]")) {
            multiType = true;
        }

        for (Object nextObject : extractValues(nextPath, theResource)) {
            if (nextObject == null) {
                continue;
            }

            ResourceIndexedSearchParamDate nextEntity;
            if (nextObject instanceof BaseDateTimeType) {
                BaseDateTimeType nextValue = (BaseDateTimeType) nextObject;
                if (nextValue.isEmpty()) {
                    continue;
                }
                nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getValue(),
                        nextValue.getValue());
            } else if (nextObject instanceof Period) {
                Period nextValue = (Period) nextObject;
                if (nextValue.isEmpty()) {
                    continue;
                }
                nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getStart(),
                        nextValue.getEnd());
            } else if (nextObject instanceof Timing) {
                Timing nextValue = (Timing) nextObject;
                if (nextValue.isEmpty()) {
                    continue;
                }
                TreeSet<Date> dates = new TreeSet<Date>();
                for (DateTimeType nextEvent : nextValue.getEvent()) {
                    if (nextEvent.getValue() != null) {
                        dates.add(nextEvent.getValue());
                    }
                }
                if (dates.isEmpty()) {
                    continue;
                }

                nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), dates.first(),
                        dates.last());
            } else if (nextObject instanceof StringType) {
                // CarePlan.activitydate can be a string
                continue;
            } else {
                if (!multiType) {
                    throw new ConfigurationException("Search param " + nextSpDef.getName()
                            + " is of unexpected datatype: " + nextObject.getClass());
                } else {
                    continue;
                }
            }
            if (nextEntity != null) {
                nextEntity.setResource(theEntity);
                retVal.add(nextEntity);
            }
        }
    }

    return retVal;
}