Example usage for java.util Set isEmpty

List of usage examples for java.util Set isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:org.davidmendoza.demo.config.StartUpConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(ComponentConfig.class, DataConfig.class, MailConfig.class, WebConfig.class);
    context.setDisplayName("DemoApp");

    FilterRegistration.Dynamic sitemeshFilter = servletContext.addFilter("sitemeshFilter",
            new ConfigurableSiteMeshFilter());
    sitemeshFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");

    FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter",
            new CharacterEncodingFilter());
    characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
    characterEncodingFilter.setInitParameter("encoding", "UTF-8");
    characterEncodingFilter.setInitParameter("forceEncoding", "true");

    servletContext.addListener(new ContextLoaderListener(context));
    //servletContext.setInitParameter("defaultHtmlEscape", "false");

    DispatcherServlet servlet = new DispatcherServlet();
    // no explicit configuration reference here: everything is configured in the root container for simplicity
    servlet.setContextConfigLocation("");

    ServletRegistration.Dynamic appServlet = servletContext.addServlet("appServlet", servlet);
    appServlet.setLoadOnStartup(1);/*from  w w w. ja va 2 s. c  o  m*/
    appServlet.setAsyncSupported(true);

    Set<String> mappingConflicts = appServlet.addMapping("/");
    if (!mappingConflicts.isEmpty()) {
        throw new IllegalStateException("'appServlet' cannot be mapped to '/' under Tomcat versions <= 7.0.14");
    }
}

From source file:org.n52.iceland.coding.encode.ResponseWriterRepository.java

private ResponseWriterKey chooseWriter(Set<Class<?>> compatible, Class<?> clazz) {
    if (compatible.isEmpty()) {
        return null;
    }// w w w  . j a v a  2s .  c  om
    Comparator<Class<?>> comparator = new ClassSimilarityComparator(clazz);
    return new ResponseWriterKey(Collections.min(compatible, comparator));
}

From source file:net.maritimecloud.identityregistry.validators.ServiceValidatorTests.java

@Test
public void validateValidService() {
    Service validService = new Service();
    validService.setName("Test service");
    validService.setMrn("urn:mrn:mcl:service:instance:testorg:test-design:test-service-instance");
    validService.setOidcAccessType("bearer-only");
    validService.setOidcRedirectUri("http://test-redirect-url-to-service.net");
    Set<ConstraintViolation<Service>> violations = validator.validate(validService);
    assertTrue(violations.isEmpty());
}

From source file:org.frat.common.controller.AbstractController.java

protected void validate(final Object validatedObj, final Class<?>[] groups) {
    final Set<ConstraintViolation<Object>> constraintViolations = validator.validate(validatedObj, groups);
    if (!constraintViolations.isEmpty()) {
        throw new ConstraintViolationException(ApplicationConstant.MANUAL_VALIDATE, constraintViolations);
    }//  w  w w. j a v a  2 s . co  m
}

From source file:com.floreantpos.model.dao.ShopFloorDAO.java

@Override
public void delete(ShopFloor shopFloor) throws HibernateException {
    Session session = null;//from   w w w.  j  a  va2 s.co  m
    Transaction tx = null;

    try {
        session = createNewSession();
        tx = session.beginTransaction();

        Set<ShopTable> tables = shopFloor.getTables();

        if (tables != null && !tables.isEmpty()) {
            shopFloor.getTables().removeAll(tables);
            saveOrUpdate(shopFloor);
        }

        super.delete(shopFloor, session);

        tx.commit();
    } catch (Exception e) {
        tx.rollback();
        LogFactory.getLog(ShopFloorDAO.class).error(e);

        throw new HibernateException(e);
    } finally {
        closeSession(session);
    }
}

From source file:net.chrissearle.flickrvote.service.DaoStatusCheckService.java

public ChallengeSummary warnForCurrent() {
    Challenge challenge = challengeDao.getCurrentChallenge();

    if (challenge == null) {
        if (logger.isLoggable(Level.INFO)) {
            logger.info("No challenge found to check");
        }//from w w  w  .  j a va2  s.co m

        return null;
    }

    Set<ImageItemStatus> status = checkSearch(challenge.getTag());

    if (!status.isEmpty()) {
        mailService.sendPost(challengeMessageService.getWarnForCurrentTitle(challenge.getTag()),
                challengeMessageService.getWarnForCurrentBody(status));
    }

    return new ChallengeSummaryInstance(challenge);
}

From source file:org.biopax.validator.rules.ComplexTwoOrMoreParticipantsRule.java

public void check(final Validation validation, Complex thing) {
    Set<PhysicalEntity> components = thing.getComponent();

    if (components.isEmpty()) {
        error(validation, thing, "complex.incomplete", false, "no components");
    } else if (components.size() == 1) {
        // one component? - then stoi.coeff. must be > 1 (dimer, trimer,..)
        PhysicalEntity pe = components.iterator().next();
        Set<Stoichiometry> stoi = thing.getComponentStoichiometry();
        String msg = "has one component";
        if (stoi.isEmpty()) {
            error(validation, thing, "complex.incomplete", false, msg + ", but no stoichiometry defined.");
        } else {//from  ww w. j  av a  2s .co  m
            if (stoi.size() > 1)
                msg += ", but multiple stoichiometries...";
            boolean ok = false;
            for (Stoichiometry s : stoi) {
                if (pe.equals(s.getPhysicalEntity()) && s.getStoichiometricCoefficient() > 1) {
                    ok = true;
                    break;
                }

                if (!pe.equals(s.getPhysicalEntity()) && s.getPhysicalEntity() != null) {
                    error(validation, thing, "complex.stoichiometry.notcomponent", false, s,
                            s.getPhysicalEntity(), pe);
                }
            }
            if (!ok) {
                error(validation, thing, "complex.incomplete", false, msg + "; which stoichiometry < 2.");
            }
        }
    }

}

From source file:de.jcup.egradle.codeassist.UserInputProposalFilter.java

/**
 * Filter given proposals by content provider information
 * /*from   w w  w . ja va2s . c om*/
 * @param proposals
 * @param contentProvider
 * @return set of proposals, never <code>null</code>
 */
public Set<Proposal> filter(Set<Proposal> proposals, ProposalFactoryContentProvider contentProvider) {
    if (proposals == null || proposals.isEmpty()) {
        return Collections.emptySet();
    }
    /* we got proposals, so filter unusable ones: */
    String entered = contentProvider.getEditorSourceEnteredAtCursorPosition();
    Set<Proposal> result = filterAndSetupProposals(proposals, entered);
    return result;
}

From source file:org.artifactory.ui.rest.service.artifacts.browse.treebrowser.tabs.general.licenses.ScanArtifactForLicensesService.java

@Override
public void execute(ArtifactoryRestRequest request, RestResponse response) {
    RepoPath path = RequestUtils.getPathFromRequest(request);
    if (!authService.canAnnotate(path)) {
        response.error("Insufficient permissions for operation").responseCode(HttpStatus.SC_UNAUTHORIZED);
        return;/*from   ww w.j  a va  2 s . co  m*/
    }
    Set<LicenseInfo> foundLicenses = addonsManager.addonByType(LicensesAddon.class).scanPathForLicenses(path);
    if (foundLicenses.isEmpty()
            || (foundLicenses.size() == 1 && foundLicenses.iterator().next().isNotFound())) {
        //Don't send "not found" object - UI gets empty array and handles
        response.iModelList(Lists.newArrayList());
    } else {
        response.iModel(foundLicenses.stream().map(GeneralTabLicenseModel::new).collect(Collectors.toList()));
    }
}

From source file:springfox.documentation.swagger.web.SwaggerApiListingReader.java

@Override
public void apply(ApiListingContext apiListingContext) {
    Class<?> controllerClass = apiListingContext.getResourceGroup().getControllerClass();
    Optional<Api> apiAnnotation = fromNullable(findAnnotation(controllerClass, Api.class));
    String description = emptyToNull(apiAnnotation.transform(descriptionExtractor()).orNull());

    Set<String> tagSet = apiAnnotation.transform(tags()).or(Sets.<String>newTreeSet());
    if (tagSet.isEmpty()) {
        tagSet.add(apiListingContext.getResourceGroup().getGroupName());
    }//  w ww  . j  a v a2 s.com
    apiListingContext.apiListingBuilder().description(description).tagNames(tagSet);
}