Example usage for org.springframework.util Assert notNull

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

Introduction

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

Prototype

public static void notNull(@Nullable Object object, Supplier<String> messageSupplier) 

Source Link

Document

Assert that an object is not null .

Usage

From source file:com.frank.search.solr.core.query.IfFunction.java

public static Builder when(Field field) {
    Assert.notNull(field, "Field cannot be 'null' in if clause.");

    return when(field.getName());
}

From source file:fr.mby.portal.coreimpl.acl.AclHelper.java

public static Set<IPermission> builePermissionSet(final IPermission... permissions) {
    Assert.notNull(permissions, "No permissions supplied !");
    final Set<IPermission> set = new HashSet<IPermission>(permissions.length);
    for (final IPermission perm : permissions) {
        if (perm != null) {
            set.add(perm);// w ww. ja v  a2  s  .c  o  m
        }
    }
    return set;
}

From source file:grails.plugin.searchable.internal.compass.support.SearchableMethodUtils.java

/**
 * Get the options Map from the given argument array
 * @param args the given array of arguments, may not be null, may be empty
 * @param defaultOptions the default options, to be merged with user options, may be null
 * @return a Map of options, never null//from   w  ww .j  a  v a2  s .  c  o  m
 */
public static Map getOptionsArgument(Object[] args, Map defaultOptions) {
    Assert.notNull(args, "args cannot be null");
    Map options = null;
    for (int i = 0, max = args.length; i < max; i++) {
        if (args[i] instanceof Map) {
            options = (Map) args[i];
            break;
        }
    }
    Map merged = new HashMap();
    if (defaultOptions != null) {
        merged.putAll(defaultOptions);
    }
    if (options != null) {
        merged.putAll(options);
    }
    return merged;
}

From source file:grails.plugin.searchable.internal.compass.CompassGpsUtils.java

/**
 * Calls CompassGps's index method, starting and stopping it if required
 * @param compassGps aCompassGps instance, cannot be null
 * @param clazz the Class to index instances of, may be null
 *//*  w  w  w . ja va 2s . com*/
public static void index(CompassGps compassGps, Class clazz) {
    Assert.notNull(compassGps, "compassGps cannot be null");

    long start = System.currentTimeMillis();
    LOG.info("Starting Searchable Plugin bulk index");
    boolean gpsRunning = compassGps.isRunning();
    try {
        if (!gpsRunning) {
            compassGps.start();
        }
        if (clazz != null) {
            compassGps.index(new Class[] { clazz });
        } else {
            compassGps.index();
        }
    } finally {
        if (!gpsRunning) {
            compassGps.stop();
        }
    }
    LOG.info("Finished Searchable Plugin bulk index, "
            + TimeUtils.formatMillisAsShortHumanReadablePeriod(System.currentTimeMillis() - start));
}

From source file:net.javacrumbs.smock.http.cxf.server.servlet.SmockServer.java

public static ServletBasedMockWebServiceClient createClient(ApplicationContext applicationContext,
        ClientInterceptor[] interceptors) {
    Assert.notNull(applicationContext, "'applicationContext' must not be null");
    return new ServletBasedMockWebServiceClient(applicationContext, interceptors);
}

From source file:com.frank.search.solr.core.query.DivideFunction.java

/**
 * creates new {@link DivideFunction.Builder} for dividing value in field with given name
 *
 * @param field must not be null//from  www  .ja v  a 2s.  co  m
 * @return
 */
public static Builder divide(Field field) {
    Assert.notNull(field, "Field cannot be 'null' for divide function.");

    return divide(field.getName());
}

From source file:com.trenako.results.PaginatedLists.java

/**
 * Returns a values page according the provided {@code Pageable}.
 *
 * @param values   the values to be paginated
 * @param paging the paging information/*from   ww  w  .  j  av  a 2s .  c  o  m*/
 * @return a {@code Page}
 */
public static <T> Page<T> paginate(List<T> values, Pageable paging) {
    Assert.notNull(values, "Values list must be not null");

    int total = values.size();
    int offset = paging.getOffset();

    if (offset > total) {
        return failbackPage();
    }

    int sIndex = start(total, offset);
    int eIndex = end(total, offset, paging.getPageSize());

    List<T> content = values.subList(sIndex, eIndex);
    return new PageImpl<>(content, paging, total);
}

From source file:com.frank.search.solr.core.query.ProductFunction.java

/**
 * @param field//from w  w  w.j a v  a2s.c  o  m
 * @return
 */
public static Builder product(Field field) {
    Assert.notNull(field, "Field must not be 'null'");

    return product(field.getName());
}

From source file:com.devnexus.ting.model.cfp.CfpSpeakerAvailability.java

public static CfpSpeakerAvailability fromKey(String cfpSpeakerAvailabilityId) {

    Assert.notNull(cfpSpeakerAvailabilityId, "Parameter cfpSpeakerAvailabilityId must not be null.");

    for (CfpSpeakerAvailability cfpSpeakerAvailability : CfpSpeakerAvailability.values()) {
        if (cfpSpeakerAvailability.getKey().equals(cfpSpeakerAvailabilityId)) {
            return cfpSpeakerAvailability;
        }/*from   w ww. j  a v a 2  s.  c om*/
    }

    return null;
}

From source file:fr.mby.opa.osgi.service.OsgiPortalServiceLocator.java

public static IPortalService retrievePortalService() {
    final IPortalService portalService = OsgiPortalServiceLocator.retrieveWebApplicationContext()
            .getBean(IPortalService.class);

    Assert.notNull(portalService, "No OSGi IPortalService service referenced in context !");

    return portalService;
}