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.netflix.simianarmy.aws.conformity.rule.BasicConformityEurekaClient.java

@Override
public boolean hasHealthCheckUrl(String region, String instanceId) {
    List<InstanceInfo> instanceInfos = discoveryClient.getInstancesById(instanceId);
    for (InstanceInfo info : instanceInfos) {
        Set<String> healthCheckUrls = info.getHealthCheckUrls();
        if (healthCheckUrls != null && !healthCheckUrls.isEmpty()) {
            return true;
        }/*  ww  w.j  a va2 s.c om*/
    }
    return false;
}

From source file:com.github.sps.metrics.opentsdb.OpenTsdb.java

private void sendHelper(Set<OpenTsdbMetric> metrics) {
    if (!metrics.isEmpty()) {
        try {//from w w  w . ja  v  a  2 s.  c o  m
            requestBuilder.setBody(mapper.writeValueAsString(metrics))
                    .execute(new AsyncCompletionHandler<Void>() {
                        @Override
                        public Void onCompleted(Response response) throws Exception {
                            if (response.getStatusCode() != 204) {
                                logger.error("send to opentsdb endpoint failed: (" + response.getStatusCode()
                                        + ") " + response.getResponseBody());
                            }
                            return null;
                        }
                    });
        } catch (Throwable ex) {
            logger.error("send to opentsdb endpoint failed", ex);
        }
    }
}

From source file:com.gu.openplatform.contentapi.ApiQuery.java

protected void addHttpParameter(Map<ApiParameter, Object> parameters, ApiParameter param,
        Set<? extends ApiUrlParameter> value) {
    if (value != null && !value.isEmpty())
        parameters.put(param, value);/*from  w w  w.java  2 s .c om*/
}

From source file:com.aerofs.baseline.json.ValidatingJacksonJaxbJsonProvider.java

@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
    Object deserialized = super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
    Preconditions.checkArgument(deserialized != null, "empty JSON body not allowed");

    Set<ConstraintViolation<Object>> violations = validator.validate(deserialized);
    if (violations != null && !violations.isEmpty()) {
        throw new ConstraintViolationException(violations);
    }/*from  w  ww.ja  va 2s .c om*/

    return deserialized;
}

From source file:org.mitre.oauth2.token.ScopeServiceAwareOAuth2RequestValidator.java

private void validateScope(Set<String> requestedScopes, Set<String> clientScopes) throws InvalidScopeException {
    if (requestedScopes != null && !requestedScopes.isEmpty()) {
        if (clientScopes != null && !clientScopes.isEmpty()) {
            if (!scopeService.scopesMatch(clientScopes, requestedScopes)) {
                throw new InvalidScopeException("Invalid scope; requested:" + requestedScopes, clientScopes);
            }//from   w  w w.ja v a 2 s  .co  m
        }
    }
}

From source file:com.flipkart.foxtrot.server.util.ManagedActionScanner.java

@Override
public void start() throws Exception {
    Reflections reflections = new Reflections("com.flipkart.foxtrot", new SubTypesScanner());
    Set<Class<? extends Action>> actions = reflections.getSubTypesOf(Action.class);
    if (actions.isEmpty()) {
        throw new Exception("No analytics actions found!!");
    }/*  w ww .j a  va2 s  . com*/
    List<NamedType> types = new Vector<NamedType>();
    for (Class<? extends Action> action : actions) {
        AnalyticsProvider analyticsProvider = action.getAnnotation(AnalyticsProvider.class);
        if (null == analyticsProvider.request() || null == analyticsProvider.opcode()
                || analyticsProvider.opcode().isEmpty() || null == analyticsProvider.response()) {
            throw new Exception("Invalid annotation on " + action.getCanonicalName());
        }
        if (analyticsProvider.opcode().equalsIgnoreCase("default")) {
            logger.warn("Action " + action.getCanonicalName() + " does not specify cache token. "
                    + "Using default cache.");
        }
        analyticsLoader.register(new ActionMetadata(analyticsProvider.request(), action,
                analyticsProvider.cacheable(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.request(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.response(), analyticsProvider.opcode()));
        logger.info("Registered action: " + action.getCanonicalName());
    }
    SubtypeResolver subtypeResolver = environment.getObjectMapperFactory().getSubtypeResolver();
    subtypeResolver.registerSubtypes(types.toArray(new NamedType[types.size()]));
}

From source file:net.sourceforge.fenixedu.presentationTier.util.CollectionFilter.java

public Set<T> filter(Set<T> elements) {
    Set<T> filtered;// ww  w.  ja va  2 s. c  o m

    if (comparator == null) {
        filtered = new HashSet<T>();
    } else {
        filtered = new TreeSet<T>(comparator);
    }

    final Set<Predicate> predicates = getPredicates();

    if (predicates == null || predicates.isEmpty()) {
        filtered.addAll(elements);
        return Collections.unmodifiableSet(filtered);
    }
    Predicate predicate;
    if (predicates.size() == 1) {
        predicate = predicates.iterator().next();
    } else {
        predicate = AllPredicate.getInstance(predicates);
    }
    for (T element : elements) {
        if (predicate.evaluate(element)) {
            filtered.add(element);
        }
    }
    return Collections.unmodifiableSet(filtered);
}

From source file:org.zalando.jpa.SimpleBeanValidator.java

/**
 * Validates a Bean for the specified goups. Prints formatted error-messages on validation-errors when 'printErrors'
 * is set to true./*from  ww w.  java2 s.  co m*/
 *
 * @param  entity
 * @param  printErrors
 * @param  groups
 */
public <T> void validate(final T entity, final boolean printErrors, final Class<?>... groups) {
    Set<ConstraintViolation<T>> violations = validator.validate(entity, groups);
    if (violations.isEmpty()) {
        return;
    }

    Set<ConstraintViolation<?>> genericViolations = new HashSet<ConstraintViolation<?>>(violations);
    if (printErrors) {
        printer.printValidationErrors(genericViolations);
    }

    throw new ConstraintViolationException(genericViolations);
}

From source file:ch.algotrader.event.dispatch.MarketDataSubscriptionRegistry.java

public void invoke(final long securityId, final Consumer<String> consumer) {

    Set<String> strategySet = this.marketDataSubscriptionMap.get(securityId);
    if (strategySet != null && !strategySet.isEmpty()) {
        for (String strategyName : strategySet) {
            consumer.accept(strategyName);
        }/*from   w w  w.  ja  v a2  s  .c  o  m*/
    }
}

From source file:se.uu.it.cs.recsys.persistence.repository.CourseRepositoryIT.java

@Test
public void testFindAllDistinctAutoGenId() {
    Set<Integer> allIds = this.courseRepository.findAllDistinctAutoGenId();

    Assert.assertTrue(!allIds.isEmpty());
}