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:com.vmware.identity.openidconnect.common.LogoutSuccessResponse.java

public LogoutSuccessResponse(URI postLogoutRedirectUri, State state, SessionID sessionId, Set<URI> logoutUris) {
    Validate.notNull(logoutUris); // pass in empty set instead
    if (!logoutUris.isEmpty() && sessionId == null) {
        throw new IllegalArgumentException("sessionId should not be null when logoutUris is non-empty");
    }//w  w w .j av a  2  s  . co  m

    this.postLogoutRedirectUri = postLogoutRedirectUri;
    this.state = state;
    this.sessionId = sessionId;
    this.logoutUris = logoutUris;
}

From source file:com.example.switchyard.idempotent.jpa.IdempotentJpaConsumer.java

private JpaTemplate jpaTemplate() {
    // Work around missing CDI support in routes
    BeanManager beanManager = getBeanManager();

    EntityManagerFactory entityManagerFactory = null;

    Set<Bean<?>> beans = beanManager.getBeans(EntityManagerFactory.class);
    if (beans != null && !beans.isEmpty()) {
        Bean<?> bean = beans.iterator().next();
        CreationalContext<?> context = beanManager.createCreationalContext(bean);
        entityManagerFactory = (EntityManagerFactory) beanManager.getReference(bean, Object.class, context);
    }/*from   www.j  a  va 2  s  . c  o m*/

    return new JpaTemplate(entityManagerFactory);
}

From source file:org.fishwife.jrugged.spring.AnnotatedMethodFilter.java

/**
 * {@inheritDoc}//from   ww w.  j  a  v  a 2 s. c  o  m
 */
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)
        throws IOException {
    AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
    Set<MethodMetadata> annotatedMethods = annotationMetadata
            .getAnnotatedMethods(annotatedClass.getCanonicalName());
    return !annotatedMethods.isEmpty();
}

From source file:org.jboss.quickstarts.wfk.contact.ContactValidator.java

/**
 * <p>/*from   w w  w . j ava  2s . c  o  m*/
 * Validates the given Contact variable and throws validation exceptions based on the type of error. If the error is standard
 * bean validation errors then it will throw a ConstraintValidationException with the set of the constraints violated.
 * </p>
 * <p>
 * If the error is caused because an existing contact with the same email is registered it throws a regular validation
 * exception so that it can be interpreted separately.
 * </p>
 * 
 * @param contact Contact to be validated
 * @throws ConstraintViolationException If Bean Validation errors exist
 * @throws ValidationException If contact with the same email already exists
 */
void validateContact(Contact contact) throws ConstraintViolationException, ValidationException {
    // Create a bean validator and check for issues.
    Set<ConstraintViolation<Contact>> violations = validator.validate(contact);

    if (!violations.isEmpty()) {
        throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(violations));
    }

    // Check the uniqueness of the email address
    if (emailAlreadyExists(contact.getEmail(), contact.getId())) {
        throw new ValidationException("Unique Email Violation");
    }
}

From source file:darks.orm.spring.MapperClassDefinitionScanner.java

@Override
protected Set<BeanDefinitionHolder> doScan(String... scanPackages) {
    Set<BeanDefinitionHolder> definitions = super.doScan(scanPackages);
    if (definitions.isEmpty()) {
        log.warn("No bean definition found in target packages " + Arrays.toString(scanPackages));
    } else {/*from w  w w .  ja v a 2  s.c o m*/
        for (BeanDefinitionHolder holder : definitions) {
            GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
            processBeanDefinition(definition);
        }
    }
    return definitions;
}

From source file:com.collective.celos.GetSchedulerTest.java

@Test
public void testGetScheduler() throws Exception {
    Set<WorkflowID> workflowIDs = celosClient.getWorkflowList();
    Assert.assertTrue(workflowIDs.isEmpty());

    File src = new File(Thread.currentThread().getContextClassLoader()
            .getResource("com/collective/celos/client/wf-list").toURI());
    FileUtils.copyDirectory(src, workflowsDir);

    workflowIDs = celosClient.getWorkflowList();
    Assert.assertTrue(workflowIDs.isEmpty());

    celosClient.clearCache();// w  ww .  ja  v a2s .c o m

    HashSet<WorkflowID> expectedResult = Sets.newHashSet(new WorkflowID("workflow-1"),
            new WorkflowID("workflow-2"), new WorkflowID("workflow-Itrntinliztin"),
            new WorkflowID("workflow-4"));
    workflowIDs = celosClient.getWorkflowList();
    Assert.assertEquals(Sets.newHashSet(workflowIDs), expectedResult);

    Scheduler scheduler = Util.requireNonNull(celosServer.getScheduler());
    Set<WorkflowID> schedWfIds = scheduler.getWorkflowConfiguration().getWorkflows().stream()
            .map(x -> x.getID()).collect(Collectors.toSet());

    Assert.assertEquals(schedWfIds, expectedResult);
}

From source file:com.acc.core.search.solrfacetsearch.provider.impl.ColorFacetValueProvider.java

@Override
public Collection<FieldValue> getFieldValues(final IndexConfig indexConfig,
        final IndexedProperty indexedProperty, final Object model) throws FieldValueProviderException {
    final ApparelStyleVariantProductModel apparelStyleModel = getApparelStyleProductModel(model);
    if (apparelStyleModel == null) {
        return Collections.emptyList();
    }//from www .j a  v a  2  s. co m

    final Set<SwatchColorEnum> colors = apparelStyleModel.getSwatchColors();

    if (colors != null && !colors.isEmpty()) {
        final Collection<FieldValue> fieldValues = new ArrayList<FieldValue>();
        for (final SwatchColorEnum color : colors) {
            fieldValues.addAll(createFieldValue(color, indexedProperty));
        }
        return fieldValues;
    } else {
        return Collections.emptyList();
    }
}

From source file:com.nike.cerberus.validation.IamRolePermissionsValidator.java

public boolean isValid(Set<IamRolePermission> iamRolePermissionSet, ConstraintValidatorContext context) {
    if (iamRolePermissionSet == null || iamRolePermissionSet.isEmpty()) {
        return true;
    }/*ww w.  j  a  v a  2 s  . c o  m*/

    boolean isValid = true;
    Set<String> iamRoles = new HashSet<>();

    for (IamRolePermission iamRolePermission : iamRolePermissionSet) {
        final String key = buildKey(iamRolePermission);
        if (iamRoles.contains(key)) {
            isValid = false;
            break;
        } else {
            iamRoles.add(key);
        }
    }

    return isValid;
}

From source file:edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions.java

public boolean isEmpty() {
    for (Set<RequestedAction> clause : clauseList) {
        if (!clause.isEmpty()) {
            return false;
        }/*from w w  w.  java 2 s. c o  m*/
    }
    return true;
}

From source file:be.wolkmaan.klimtoren.web.config.WebAppInitializer.java

public void logbackServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic servlet = servletContext.addServlet("logbackStatus",
            new ch.qos.logback.classic.ViewStatusMessagesServlet());
    servlet.setLoadOnStartup(3);/*from   ww  w.  j  a v a 2  s.  c  o  m*/
    Set<String> mappingConflicts = servlet.addMapping("/admin/logbackStatus/*");

    if (!mappingConflicts.isEmpty()) {
        for (String s : mappingConflicts) {
            logger.error("Mapping conflict: " + s);
        }
        throw new IllegalStateException("servlet cannot be mapped");
    }
}