Example usage for org.springframework.util Assert notEmpty

List of usage examples for org.springframework.util Assert notEmpty

Introduction

In this page you can find the example usage for org.springframework.util Assert notEmpty.

Prototype

public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier) 

Source Link

Document

Assert that a Map contains entries; that is, it must not be null and must contain at least one entry.

Usage

From source file:com.flipkart.aesop.runtime.clusterclient.DefaultClusterClientFactory.java

/**
 * Interface method implementation. Checks for mandatory dependencies and initializes this Relay Client
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 *///from  w w  w  .  j  a va  2s  .c o  m
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.clientClusterConfig,
            "'clientClusterConfig' cannot be null. This Relay Cluster Client will not be initialized");
    Assert.notEmpty(this.clusterRegistrations,
            "'clusterRegistrations' cannot be empty. No Cluster Registrations.");
}

From source file:gov.nih.nci.cabig.ctms.acegi.acls.dao.impl.BasicAclLookupStrategy.java

public Map readAclsById(ObjectIdentity[] objects, Sid[] sids) {

    Assert.isTrue(batchSize >= 1, "BatchSize must be >= 1");
    Assert.notEmpty(objects, "Objects to lookup required");

    // Map<ObjectIdentity,Acl>
    Map result = new HashMap(); // contains FULLY loaded Acl objects

    Set currentBatchToLoad = new HashSet(); // contains ObjectIdentitys

    for (int i = 0; i < objects.length; i++) {
        // Check we don't already have this ACL in the results
        if (result.containsKey(objects[i])) {
            continue; // already in results, so move to next element
        }//from  w ww.java  2  s .  c  om

        // Check cache for the present ACL entry
        Acl acl = aclCache.getFromCache(objects[i]);

        // Ensure any cached element supports all the requested SIDs
        // (they should always, as our base impl doesn't filter on SID)
        if (acl != null) {
            if (acl.isSidLoaded(sids)) {
                result.put(acl.getObjectIdentity(), acl);

                continue; // now in results, so move to next element
            } else {
                throw new IllegalStateException(
                        "Error: SID-filtered element detected when implementation does not perform SID filtering - have you added something to the cache manually?");
            }
        }

        // To get this far, we have no choice but to retrieve it from DB
        // (although we don't do it until we get a batch of them to load)
        currentBatchToLoad.add(objects[i]);

        // Is it time to load from DB the currentBatchToLoad?
        if ((currentBatchToLoad.size() == this.batchSize) || ((i + 1) == objects.length)) {
            Map loadedBatch = lookupObjectIdentities(
                    (ObjectIdentity[]) currentBatchToLoad.toArray(new ObjectIdentity[] {}), sids);

            // Add loaded batch (all elements 100% initialized) to results
            result.putAll(loadedBatch);

            // Add the loaded batch to the cache
            Iterator loadedAclIterator = loadedBatch.values().iterator();

            while (loadedAclIterator.hasNext()) {
                aclCache.putInCache((AclImpl) loadedAclIterator.next());
            }

            currentBatchToLoad.clear();
        }
    }

    // Now we're done, check every requested object identity was found
    // (throw NotFoundException if needed)
    for (int i = 0; i < objects.length; i++) {
        if (!result.containsKey(objects[i])) {
            throw new NotFoundException(
                    "Unable to find ACL information for object identity '" + objects[i].toString() + "'");
        }
    }

    return result;

}

From source file:org.cf.serviceregistrybroker.model.Cost.java

public Map<String, Double> getAmount() {
    Assert.notEmpty(this.amount, "Cost must specify at least one amount");
    return this.amount;
}

From source file:fr.acxio.tools.agia.alfresco.configuration.NodeDefinitionFactoryBean.java

public void afterPropertiesSet() {
    Assert.notEmpty(propertiesDefinitions, "The node definition must have some properties");
}

From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementService.java

@Override
public Map<String, Etablissement> retrieveEtablissementsByCodes(final Collection<String> codes) {
    Assert.notEmpty(codes, "No Etablissement code supplied !");

    final Map<String, Etablissement> etabs = new HashMap<String, Etablissement>(codes.size());

    this.loadEtablissementCacheIfExpired();

    for (final String code : codes) {
        final Etablissement etab = this.retrieveEtablissementsByCode(code);
        if (etab != null) {
            etabs.put(code, etab);/* w  ww  .  j  a  v  a2s . c om*/
        }
    }

    CachingEtablissementService.LOG.debug("{} etablissement(s) found.", etabs.size());

    return etabs;
}

From source file:de.extra.client.core.builder.impl.plugins.DataSourceSingleInputDataPluginsBuilder.java

/**
 * Erstellt die SenderInformationen im Kontext von Header (non-Javadoc)
 * //  w  ww  .  j a va  2 s  .co m
 * @see de.extra.client.core.builder.IXmlComplexTypeBuilder#buildXmlFragment(de.extra.client.core.model.SenderDataBean,
 *      de.extra.client.core.model.ExtraProfileConfiguration)
 */
@Override
public Object buildXmlFragment(final IInputDataContainer senderData, final IExtraProfileConfiguration config) {
    Assert.notNull(senderData, "InputDataContainer is null");
    final List<ISingleInputData> content = senderData.getContent();
    // Hier wird vorerst nur eine InputData erwartet
    Assert.notEmpty(content, "Keine InputDaten vorhanden");
    Assert.isTrue(content.size() == 1,
            "InputDataContainer beinhaltet mehr als 1 Element. Erwartet ist nur 1 Element");
    final ISingleInputData iSingleInputData = content.get(0);
    final DataSource dataSource = new DataSource();
    if (ISingleContentInputData.class.isAssignableFrom(iSingleInputData.getClass())) {
        final ISingleContentInputData singleContentInputData = ISingleContentInputData.class
                .cast(iSingleInputData);
        final DataSourcePluginDescription dataSourcePluginDescriptor = getDataSourcePluginDescriptor(
                singleContentInputData);
        if (dataSourcePluginDescriptor != null) {
            final DataContainerType dataContainer = new DataContainerType();
            dataContainer.setName(dataSourcePluginDescriptor.getName());
            dataSourcePluginDescriptor.getType();
            dataContainer.setType(dataSourcePluginDescriptor.getType().getDataContainerCode());
            // 27.12.2012 Die Semantik des Feldes ist unklar. Ist das
            // Erstellungsdatum des Files?
            final GregorianCalendar calenderCreated = new GregorianCalendar();
            calenderCreated.setTime(dataSourcePluginDescriptor.getCreated());
            dataContainer.setCreated(calenderCreated);
            dataContainer.setEncoding(dataSourcePluginDescriptor.getEncoding());
            dataSource.setDataContainer(dataContainer);
        }
    }
    LOG.debug("DataSourcePlugin created.");
    return dataSource;

}

From source file:org.motechproject.server.event.annotations.MotechListenerNamedParametersProxy.java

@Override
public void callHandler(MotechEvent event) {
    List<Object> args = new ArrayList<Object>();
    Class<?>[] paramTypes = method.getParameterTypes();
    Annotation[][] paramAnnotations = method.getParameterAnnotations();
    Assert.isTrue(paramTypes.length == paramAnnotations.length);
    for (int i = 0; i < paramTypes.length; i++) {
        Class<?> t = paramTypes[i];
        Assert.notEmpty(paramAnnotations[i], "MotechParam(name) annotation is required for each parameter.");
        //TODO now assuming only MotechParam annotation is present...
        Assert.isAssignable(MotechParam.class, paramAnnotations[i][0].getClass());
        MotechParam annotation = (MotechParam) paramAnnotations[i][0];
        Object arg = event.getParameters().get(annotation.value());
        Assert.notNull(arg, String.format("parameter #%d with name:\"%s\" not found or null prameter passed.",
                i, annotation.value()));
        Assert.isAssignable(t, arg.getClass(), String.format("Parameter #%d expected subtypes of %s passed %s.",
                i, t.getName(), arg.getClass().getName()));
        args.add(arg);//from w ww. ja v a  2  s  .  c  o  m
    }
    ReflectionUtils.invokeMethod(method, bean, args.toArray());

}

From source file:org.cleverbus.api.route.XPathValidator.java

/**
 * Creates new XPath validator with empty parent element.
 *
 * @param ns the namespace(s)// w w w .  j  a  v  a2s. c om
 * @param elements the elements
 */
public XPathValidator(Namespaces ns, String... elements) {
    Assert.notNull(ns, "the ns must not be null");
    Assert.notEmpty(elements, "the elements must not be empty");

    this.ns = ns;
    this.elements = elements;
}

From source file:jails.http.converter.AbstractHttpMessageConverter.java

/**
 * Set the list of {@link MediaType} objects supported by this converter.
 *//*from   w  ww.  j  a v a2 s . c o  m*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
    Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' must not be empty");
    this.supportedMediaTypes = new ArrayList<MediaType>(supportedMediaTypes);
}

From source file:com.silentwu.schedule.component.WebAnalyzeService.java

public List<Schedule> findScheduleFromHtml(String cityId, String cityName, String targetName, String searchDate)
        throws IOException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("cityId", cityId);
    params.put("cityName", cityName);
    params.put("targetNmae", targetName);
    params.put("searchDate", searchDate);
    String html = HttpUtils.doGet(SCHEDULE_URL, params);

    Map<String, Object> map = htmlConvertToMap(html);
    Assert.isTrue((Boolean) map.get("success"), "?");

    List<Schedule> schedules = new ArrayList<Schedule>();
    for (Object schedule : (ArrayList) map.get("data")) {
        schedules.add(fromMap((Map) schedule));
    }/*from  ww  w.  j a  v  a2  s  . c o  m*/
    Assert.notEmpty(schedules, "?");
    return schedules;
}