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.haulmont.cuba.gui.app.core.scheduled.ScheduledTaskBrowser.java

protected boolean checkAllTasksIsNotActive(Set<ScheduledTask> tasks) {
    if (!tasks.isEmpty()) {
        for (ScheduledTask task : tasks) {
            if (BooleanUtils.isTrue(task.getActive())) {
                return false;
            }/*  w  w w .  ja  va  2s .  co m*/
        }
        return true;
    } else {
        return false;
    }
}

From source file:com.opentable.exception.ExceptionClientResponseFilter.java

private OTApiException toException(final Map<String, Object> fields) {
    final String type = Objects.toString(fields.get(OTApiException.ERROR_TYPE));

    final Set<ExceptionReviver> set = revivers.get(type);
    if (set.isEmpty()) {
        LOG.error("Unknown exception type '{}'", type);
        return makeUnknownException(fields);
    }/* w w  w. j  a  v  a  2  s . c  o  m*/
    for (final ExceptionReviver er : set) {
        final OTApiException ex = er.apply(fields);
        if (ex != null) {
            return ex;
        }
    }
    LOG.error("No registered handler handled {}", fields);
    return makeUnknownException(fields);
}

From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageRestClient.java

@Override
public List<CoursePageNotification> getCoursePageNotifications(Set<String> courseImplementationIds,
        LocalDateTime from, Locale locale) {
    if (courseImplementationIds.isEmpty()) {
        return newArrayList();
    }/*from   w w w.ja  va 2s .  c  o  m*/

    ResponseEntity<List<CoursePageNotification>> responseEntity = restTemplate.exchange(
            "{baseUrl}/course_implementation_activity"
                    + "?course_implementation_id={courseImplementationIds}&timestamp={from}&langcode={locale}",
            HttpMethod.GET, null, new ParameterizedTypeReference<List<CoursePageNotification>>() {
            }, baseUrl, courseImplementationIds.stream().collect(Collectors.joining(",")),
            from.format(DateFormatter.COURSE_PAGE_DATE_TIME_FORMATTER), locale.getLanguage());

    return Optional.ofNullable(responseEntity.getBody()).orElse(newArrayList());
}

From source file:org.shaigor.rest.retro.config.WebAppInitializer.java

/**
 * Registers dispatcher servlet that will make MVC tick
 * @param servletContext to be used during creation and registration
 * @param rootContext web application context to be used during creation and registration
 *//*from   www  .j a  va2s.c  o  m*/
private void configureSpringMvc(ServletContext servletContext, WebApplicationContext rootContext) {
    AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext();
    mvcContext.register(WordsSereviceConfig.class, InsecureWebMvcConfigurer.class);

    mvcContext.setParent(rootContext);

    ServletRegistration.Dynamic appServlet = servletContext.addServlet("webservice",
            new DispatcherServlet(mvcContext));
    appServlet.setLoadOnStartup(1);
    Set<String> mappingConflicts = appServlet.addMapping("/");

    if (!mappingConflicts.isEmpty()) {
        for (String s : mappingConflicts) {
            LOG.error("Mapping conflict: " + s);
        }
        throw new IllegalStateException("'webservice' cannot be mapped to '/'");
    }
}

From source file:se.uu.it.cs.recsys.constraint.builder.LevelDomainBuilder.java

public Map<CourseLevel, Set<Integer>> getLevelAndIdMappingFor(Set<Integer> idSet) {
    if (idSet == null || idSet.isEmpty()) {
        LOGGER.warn("Does not make sense to put null or empty set, right?");
        return Collections.emptyMap();
    }/*w  ww  .  jav  a2 s .co  m*/

    Map<CourseLevel, Set<Integer>> levelAndIds = new HashMap<>();

    this.courseRepository.findByAutoGenIds(idSet).stream()
            .forEach(course -> checkCourseLevelAndPutToMap(course, levelAndIds));

    return levelAndIds;
}

From source file:io.microprofile.showcase.speaker.domain.VenueJavaOne2016Test.java

@Test
public void testGetSpeakers() throws Exception {

    final Set<Speaker> speakers = new VenueJavaOne2016().getSpeakers();

    Assert.assertFalse("Failed to get any speakers", speakers.isEmpty());

    for (final Speaker speaker : speakers) {
        Assert.assertNotNull(speaker.getNameLast());
        this.log.info(speaker.getNameFirst() + " " + speaker.getNameLast());
    }//from w  w  w . ja v a2  s.  co m
}

From source file:com.haulmont.cuba.gui.app.core.scheduled.ScheduledTaskBrowser.java

protected boolean checkAllTasksHaveSameStatus(Set<ScheduledTask> tasks) {
    if (!tasks.isEmpty()) {
        boolean firstItemState = BooleanUtils.isTrue(tasks.iterator().next().getActive());

        for (ScheduledTask task : tasks) {
            if (BooleanUtils.isTrue(task.getActive()) != firstItemState) {
                return false;
            }/* w ww  .  j  ava2s .  co m*/
        }
        return true;
    } else {
        return false;
    }
}

From source file:org.commonjava.cartographer.request.RepositoryContentRequest.java

public void setMetas(final Set<String> metas) {
    this.metas = metas == null || metas.isEmpty() ? null : new TreeSet<>(metas);
}

From source file:com.linkedin.restli.internal.server.model.RestLiApiBuilder.java

@Override
public Map<String, ResourceModel> build() {
    RestLiClasspathScanner scanner = new RestLiClasspathScanner(_packageNames, _classNames,
            Thread.currentThread().getContextClassLoader());
    scanner.scanPackages();/*ww w. j  a v  a 2  s .com*/
    final String errorMessage = scanner.scanClasses();
    if (!errorMessage.isEmpty()) {
        _log.error(errorMessage);
    }

    Set<Class<?>> annotatedClasses = scanner.getMatchedClasses();

    if (annotatedClasses.isEmpty()) {
        StringBuilder sb = new StringBuilder("Could not find any rest-li classes in the following packages: "
                + StringUtils.join(_packageNames, ','));
        throw new ResourceConfigException(sb.toString());
    }

    return buildResourceModels(annotatedClasses);
}

From source file:com.aceevo.ursus.config.UrsusConfigurationFactory.java

private T validate(T ursusHttpServerConfig) {
    Set<ConstraintViolation<T>> violationSet = validator.validate(ursusHttpServerConfig);
    if (!violationSet.isEmpty()) {
        StringBuilder stringBuilder = new StringBuilder();
        for (ConstraintViolation constraintViolation : violationSet) {
            stringBuilder.append(constraintViolation.getPropertyPath());
            stringBuilder.append(" ");
            stringBuilder.append(constraintViolation.getMessage());
            stringBuilder.append(System.lineSeparator());
        }//ww  w.  j  ava2  s  .  c  om
        throw new RuntimeException(stringBuilder.substring(0, stringBuilder.length() - 1));
    }

    return ursusHttpServerConfig;
}