Example usage for java.util SortedSet isEmpty

List of usage examples for java.util SortedSet isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessReadLock.java

/**
 * {@inheritDoc}//  w w  w  .  j  av  a 2  s. c o m
 */
@Override
protected String getLockPath(String createdZNode, List<String> children) throws IOException {
    TreeSet<String> writeChildren = new TreeSet<String>(ZNodeComparator.COMPARATOR);
    for (String child : children) {
        if (isChildWriteLock(child)) {
            writeChildren.add(child);
        }
    }
    if (writeChildren.isEmpty()) {
        return null;
    }
    SortedSet<String> lowerChildren = writeChildren.headSet(createdZNode);
    if (lowerChildren.isEmpty()) {
        return null;
    }
    String pathToWatch = lowerChildren.last();
    String nodeHoldingLock = lowerChildren.first();
    String znode = ZKUtil.joinZNode(parentLockNode, nodeHoldingLock);
    handleLockMetadata(znode);

    return pathToWatch;
}

From source file:org.apache.hadoop.hbase.zookeeper.lock.HReadLockImpl.java

/**
 * {@inheritDoc}/*w ww. ja v  a  2  s .co m*/
 */
@Override
protected String getLockPath(String createdZNode, List<String> children)
        throws IOException, InterruptedException {
    TreeSet<String> writeChildren = new TreeSet<String>(new ZNodeComparator(zkWrapper.getIdentifier()));
    for (String child : children) {
        if (isWriteChild(child)) {
            writeChildren.add(child);
        }
    }
    if (writeChildren.isEmpty()) {
        return null;
    }
    SortedSet<String> lowerChildren = writeChildren.headSet(createdZNode);
    if (lowerChildren.isEmpty()) {
        return null;
    }
    String pathToWatch = lowerChildren.last();
    String nodeHoldingLock = lowerChildren.first();
    try {
        handleLockMetadata(nodeHoldingLock);
    } catch (IOException e) {
        LOG.warn("Error processing lock metadata in " + nodeHoldingLock, e);
    }
    return pathToWatch;
}

From source file:uk.co.unclealex.process.spring.PackageCheckingPostProcessor.java

/**
 * {@inheritDoc}/* ww  w .  j a va2 s .  co m*/
 */
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    SortedSet<String> missingPackages = getPackageChecker().listMissingPackages(bean);
    if (!missingPackages.isEmpty()) {
        throw new BeanDefinitionValidationException(
                String.format("Bean %s requires the following missing packages: %s", beanName,
                        Joiner.on(", ").join(missingPackages)));
    }
    return bean;
}

From source file:org.sakuli.services.forwarder.database.DatabaseResultServiceImpl.java

@Override
public void saveAllResults() {
    LOGGER.info("======= SAVE RESULTS TO DATABASE ======");
    ;/*from   w  ww  .j  a  v a2s  .c o m*/
    try {
        daoTestSuite.saveTestSuiteResult();
        daoTestSuite.saveTestSuiteToSahiJobs();

        if (!CollectionUtils.isEmpty(testSuite.getTestCases())) {
            for (TestCase tc : testSuite.getTestCasesAsSortedSet()) {
                //write testcase and steps to DB
                daoTestCase.saveTestCaseResult(tc);

                LOGGER.info("... try to save all STEPS for test case '" + tc.getId() + "'!");
                SortedSet<TestCaseStep> steps = tc.getStepsAsSortedSet();
                if (!steps.isEmpty()) {
                    daoTestCaseStep.saveTestCaseSteps(steps, tc.getDbPrimaryKey());
                    LOGGER.info("all STEPS for '" + tc.getId() + "' saved!");
                } else {
                    LOGGER.info("no STEPS for '\" + tc.getId() +\"'found => no STEPS saved in DB!");
                }
            }
        }
        LOGGER.info("======= FINISHED: SAVE RESULTS TO DATABASE ======");
    } catch (Throwable e) {
        exceptionHandler.handleException(new SakuliForwarderException(e,
                String.format("error by saving the results to the database [%s]", testSuite.toString())), true);
    }
}

From source file:org.apache.hadoop.hbase.regionserver.MutableCellSetSegment.java

@Override
public Cell getFirstAfter(Cell cell) {
    SortedSet<Cell> snTailSet = tailSet(cell);
    if (!snTailSet.isEmpty()) {
        return snTailSet.first();
    }//from   w w w .j av a  2 s.com
    return null;
}

From source file:org.apache.cayenne.access.loader.filters.TableFilter.java

/**
 * Includes can contain only One includetable
 *
 * @param includes//from   w  ww  .  j a va 2 s .c  o  m
 * @param excludes
 */
public TableFilter(SortedSet<IncludeTableFilter> includes, SortedSet<Pattern> excludes) {
    if (includes.isEmpty()) {
        throw new IllegalArgumentException("TableFilter should contain at least one IncludeTableFilter always "
                + "and it is builder responsibility. If you need table filter without includes, use EmptyTableFilter");
    }

    this.includes = includes;
    this.excludes = excludes;
}

From source file:com.migratebird.script.executedscriptinfo.impl.DefaultExecutedScriptInfoSourceMarkErrorScriptsAsSuccessfulTest.java

@Test
public void noScripts() {
    SortedSet<ExecutedScript> before = executedScriptInfoSource.getExecutedScripts();
    assertTrue(before.isEmpty());

    executedScriptInfoSource.markErrorScriptsAsSuccessful();

    SortedSet<ExecutedScript> after = executedScriptInfoSource.getExecutedScripts();
    assertTrue(after.isEmpty());//from w w  w  . j a v a  2 s.co  m
}

From source file:com.migratebird.script.executedscriptinfo.impl.DefaultExecutedScriptInfoSourceRemoveErrorScriptsTest.java

@Test
public void failedScripts() throws Exception {
    registerFailedScripts();/*w  w  w  .  j a v a 2 s  .  c om*/
    SortedSet<ExecutedScript> before = executedScriptInfoSource.getExecutedScripts();
    AssertUtils.assertPropertyLenientEquals("successful", asList(false, false, false), before);

    executedScriptInfoSource.removeErrorScripts();

    SortedSet<ExecutedScript> after = executedScriptInfoSource.getExecutedScripts();
    assertTrue(after.isEmpty());
}

From source file:com.migratebird.script.executedscriptinfo.impl.DefaultExecutedScriptInfoSourceRemoveErrorScriptsTest.java

@Test
public void noScripts() {
    SortedSet<ExecutedScript> before = executedScriptInfoSource.getExecutedScripts();
    assertTrue(before.isEmpty());

    executedScriptInfoSource.removeErrorScripts();

    SortedSet<ExecutedScript> after = executedScriptInfoSource.getExecutedScripts();
    assertTrue(after.isEmpty());/*from   w w w . j av a 2 s.c  o m*/
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectIssuesBox.java

@Override
@SuppressWarnings("nls")
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_ISSUES_INFOBOX);
    layout.setSizeFull();/*  w  w w .  j a  v a  2s.  c o  m*/

    IssuesService issuesService = Services.getService(IssuesService.class);
    if (issuesService != null) {
        Issues issues = issuesService.loadEntity(Issues.class, project.getUuid());
        StringBuilder sb = new StringBuilder();
        if (issues != null) {
            if (issues.isStale()) {
                sb.append("<ul><li class=\"STALE\">No information about issues available.</li></ul>");
            } else {
                SortedSet<Issue> issueSet = issues.getIssues();
                if (!issueSet.isEmpty()) {
                    sb.append(Issue.asHTMLList(null, issueSet));
                    if (util.isUserProjectAdmin(project)) {
                        sb.append("<p>Click <a href=\"").append(Consts.URL_PROJECTS).append("/")
                                .append(project.getProjectId()).append("?").append(Consts.PARAM_ACTION)
                                .append("=").append(Consts.PARAM_VALUE_EDIT).append("\">here</a> to correct ");
                        sb.append((issueSet.size() == 1) ? "this issue" : "these issues");
                        sb.append(".</p>");
                    }
                }
            }
            if (util.isUserProjectAdmin(project)) {
                sb.append("<p>Click <a href=\"").append(Consts.URL_PROJECTS).append("/");
                sb.append(project.getProjectId()).append("?").append(Consts.PARAM_ACTION).append("=");
                sb.append(Consts.PARAM_VALUE_VALIDATE).append("\">here</a> to validate the project now.</p>");
            }
            createLabel(layout, sb.toString(), STYLE_ISSUES);
        }
    }

    return layout;
}