Example usage for org.springframework.util CollectionUtils isEmpty

List of usage examples for org.springframework.util CollectionUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util CollectionUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Map<?, ?> map) 

Source Link

Document

Return true if the supplied Map is null or empty.

Usage

From source file:org.openlmis.fulfillment.service.referencedata.FacilityReferenceDataService.java

/**
 * Finds facilities by their ids.//from  w  ww .  j a v a  2s  .c om
 *
 * @param ids ids to look for.
 * @return a page of facilitiesg
 */
public Collection<FacilityDto> findByIds(Collection<UUID> ids) {
    if (CollectionUtils.isEmpty(ids)) {
        return Collections.emptyList();
    }
    return findAll("", RequestParameters.init().set("id", ids));
}

From source file:org.openlmis.fulfillment.service.referencedata.OrderableReferenceDataService.java

/**
 * Finds orderables by their ids./* ww w . ja v a2 s . co m*/
 *
 * @param ids ids to look for.
 * @return a page of orderables
 */
public List<OrderableDto> findByIds(Collection<UUID> ids) {
    if (CollectionUtils.isEmpty(ids)) {
        return Collections.emptyList();
    }
    return getPage(RequestParameters.init().set("id", ids)).getContent();
}

From source file:com.microsoft.exchange.DateHelpTest.java

@Test
public void systemTimeZone() {
    List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs());
    assertFalse(CollectionUtils.isEmpty(availableIDs));
    assertTrue(availableIDs.contains(TimeZones.UTC_ID));
    assertTrue(availableIDs.contains("UTC"));

    TimeZone ical4jUTC = TimeZone.getTimeZone(TimeZones.UTC_ID);
    TimeZone sysUTC = TimeZone.getTimeZone("UTC");

    assertEquals(ical4jUTC.getDSTSavings(), sysUTC.getDSTSavings());
    assertEquals(ical4jUTC.getRawOffset(), sysUTC.getRawOffset());
    assertTrue(ical4jUTC.hasSameRules(sysUTC));

    TimeZone origDefaultTimeZone = TimeZone.getDefault();
    assertNotNull(origDefaultTimeZone);//  w  w w .  j av  a 2  s .co m
    assertEquals(TimeZone.getDefault().getRawOffset(), origDefaultTimeZone.getRawOffset());

    log.info("TimeZone.DisplayName=" + origDefaultTimeZone.getDisplayName());
    log.info("TimeZone.ID=" + origDefaultTimeZone.getID());
    log.info("TimeZone.DSTSavings=" + origDefaultTimeZone.getDSTSavings());
    log.info("TimeZone.RawOffset=" + origDefaultTimeZone.getRawOffset());
    log.info("TimeZone.useDaylightTime=" + origDefaultTimeZone.useDaylightTime());

    TimeZone.setDefault(ical4jUTC);
    assertEquals(ical4jUTC, TimeZone.getDefault());
    log.info(" -- Defualt Time Zone has been changed successfully! -- ");

    TimeZone newDefaultTimeZone = TimeZone.getDefault();
    log.info("TimeZone.DisplayName=" + newDefaultTimeZone.getDisplayName());
    log.info("TimeZone.ID=" + newDefaultTimeZone.getID());
    log.info("TimeZone.DSTSavings=" + newDefaultTimeZone.getDSTSavings());
    log.info("TimeZone.RawOffset=" + newDefaultTimeZone.getRawOffset());
    log.info("TimeZone.useDaylightTime=" + newDefaultTimeZone.useDaylightTime());
}

From source file:io.cloudslang.engine.data.SqlInQueryReader.java

private <T> List<T> readItems(Set<String> items, SqlInQueryCallback<T> callback) {
    Set<String> source = new HashSet<>(items);
    List<T> results = new LinkedList<>();
    do {/*  w  w  w . j  av  a 2 s  .  c  o  m*/
        Set<String> itemsToRead = extractAndRemoveUpToLimit(source, DATABASE_IN_CLAUSE_LIMIT);
        List<T> result = callback.readItems(itemsToRead);
        if (result != null) {
            results.addAll(result);
        }
    } while (!CollectionUtils.isEmpty(source));
    return results;
}

From source file:com.qpark.eip.core.spring.JAXBElementAwarePayloadTypeRouter.java

/**
 * Selects the most appropriate channel name matching channel identifiers
 * which are the fully qualified class names encountered while traversing
 * the payload type hierarchy. To resolve ties and conflicts (e.g.,
 * Serializable and String) it will match: 1. Type name to channel
 * identifier else... 2. Name of the subclass of the type to channel
 * identifier else... 3. Name of the Interface of the type to channel
 * identifier while also preferring direct interface over indirect subclass
 *///  w  ww. ja  v  a  2 s  .  c  o m
@Override
protected List<Object> getChannelKeys(final Message<?> message) {
    if (CollectionUtils.isEmpty(this.getChannelMappings())) {
        return null;
    }
    Object o = message.getPayload();
    Class<?> type = message.getPayload().getClass();
    if (o.getClass().equals(JAXBElement.class)) {
        type = ((JAXBElement<?>) o).getDeclaredType();
    }
    boolean isArray = type.isArray();
    if (isArray) {
        type = type.getComponentType();
    }
    String closestMatch = this.findClosestMatch(type, isArray);
    return (closestMatch != null) ? Collections.<Object>singletonList(closestMatch) : null;
}

From source file:com.consol.citrus.samples.kubernetes.ListKubernetesResourcesIT.java

@Test
@CitrusTest/*from  w w w .j av a 2s . c o  m*/
public void testListEndpoints() {
    kubernetes().client(k8sClient).endpoints().list().namespace("default").validate((result, context) -> {
        Assert.assertFalse(CollectionUtils.isEmpty(result.getResult().getItems()));
    });
}

From source file:org.duracloud.mill.audit.generator.AuditLogGenerator.java

public void execute() {
    log.info("executing generator...");
    long itemsWritten = 0;
    long totalItemsWritten = 0;
    try {/*from  w  ww .j av a 2s .  c om*/
        // Reads the Audit table, writes each item it finds to a
        // space-specific file
        int maxItemsPerRequest = Integer.parseInt(System.getProperty("max-audit-items-per-request", "1000"));
        Pageable pageRequest = new PageRequest(0, maxItemsPerRequest);

        while (true) {
            List<JpaAuditLogItem> items = auditLogItemRepo.findByWrittenFalseOrderByTimestampAsc(pageRequest);
            if (CollectionUtils.isEmpty(items)) {
                log.info("No audit items found for processing: nowhere to go, nothing to do.", items.size());
                break;
            }

            log.info("{} audit items read from the the jpa repo.", items.size());

            for (JpaAuditLogItem item : items) {
                write(item);
            }

            itemsWritten += items.size();
            totalItemsWritten += itemsWritten;
            log.info("{} audit items written.", items.size());

            if (itemsWritten >= 100000) {
                log.info("{} items written since last flush.  Flushing logs...", itemsWritten);
                logManager.flushLogs();
                itemsWritten = 0;
                log.info("Purge expired...");
                logManager.purgeExpired();
            }
        }

        log.info("{} total audit items written in this run.", totalItemsWritten);
        log.info("perform final purge of expired items.");
        this.logManager.purgeExpired();
        log.info("purge complete.");
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException(ex);
    } finally {
        // close all logs
        try {
            logManager.flushLogs();
            log.info("audit log run completed.");
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new RuntimeException(ex);
        }
    }
}

From source file:it.inserpio.neo4art.repository.MuseumRepositoryTest.java

@Test
public void shouldRetrieveMuseumsHostingVanGoghArtworks() {
    List<Museum> museums = this.museumRepository.findMuseumByArtist(0);

    Assert.assertNotNull(museums);// w w  w.  j a  va  2 s  .  c o m
    Assert.assertFalse(CollectionUtils.isEmpty(museums));

    System.out.println(museums.size());
}

From source file:com.payu.ratel.client.inmemory.RatelServerFetcher.java

@Override
public String fetchServiceAddress(String serviceName) {
    LOGGER.info("Fetching addresses from ratel server for {}", serviceName);
    final ArrayList<String> serviceAddressList = Lists.newArrayList(fetchServiceAddresses(serviceName));

    if (CollectionUtils.isEmpty(serviceAddressList)) {
        return "";
    }//from  w w  w.  j av  a 2 s  . c  om

    Collections.sort(serviceAddressList);

    int thisIndex = Math.abs(index.getAndIncrement());
    return serviceAddressList.get(thisIndex % serviceAddressList.size());
}

From source file:org.duracloud.snapshot.service.impl.ContentPropertiesFileReaderTest.java

/**
 * @param props/*from w  w w.java2  s .c o  m*/
 */
private void verifyProps(ContentProperties props) {
    Assert.assertNotNull(props.getContentId());
    Assert.assertTrue(!CollectionUtils.isEmpty(props.getProperties()));

    // Verify that the property names do not match their values
    for (String key : props.getProperties().keySet()) {
        Assert.assertNotEquals(key, props.getProperties().get(key));
    }
}