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.NotFunction.java

/**
 * @param condition must not be null// www . j  a  va  2 s .  co m
 * @return
 */
public static NotFunction not(Function condition) {
    Assert.notNull(condition, "Condition for not function must not be 'null'");

    return new NotFunction(condition);
}

From source file:lab.mage.spring.cassandra.connector.core.OptionProvider.java

@Nonnull
public static final Mapper.Option readConsistencyLevel(@Nonnull final Environment env) {
    Assert.notNull(env, "An environment must be given!");
    if (OptionProvider.CACHED_OPTIONS.isEmpty()) {
        OptionProvider.lazyOptionInit(env);
    }/*from w ww  . j av  a 2s.com*/
    return OptionProvider.CACHED_OPTIONS.get(CassandraConnectorConstants.CONSISTENCY_LEVEL_READ_PROP);
}

From source file:net.javacrumbs.smock.axis2.server.SmockServer.java

public static ConfigurationContext createConfigurationContextFromResource(Resource axis2Repository) {
    try {//from  w  ww .  j a  v  a2 s.  c  om
        Assert.notNull(axis2Repository, "axis2Repository can not be null");
        return ConfigurationContextFactory
                .createConfigurationContextFromFileSystem(axis2Repository.getFile().getAbsolutePath());
    } catch (Exception e) {
        throw new IllegalStateException("Can not load Axis2 repository.", e);
    }
}

From source file:org.cleverbus.api.common.ExchangeHelper.java

/**
 * Returns the {@link TraceHeader} or throws an {@link IllegalDataException} if it is not present and is mandatory.
 * @param exchange the exchange message//w  w w  .j av a 2 s.  com
 * @param mandatory true if trace header is mandatory output
 * @return the {@link TraceHeader} object as header value from exchange
 */
@Nullable
public static TraceHeader getTraceHeader(Exchange exchange, boolean mandatory) {
    Assert.notNull(exchange, "the exchange must not be null");

    TraceHeader answer = exchange.getIn().getHeader(TRACE_HEADER, TraceHeader.class);

    if (mandatory) {
        Constraints.notNull(answer, "TraceHeader is mandatory and is not included in this exchange.");
    }
    return answer;
}

From source file:net.sf.oval.integration.spring.SpringInjector.java

public static SpringInjector get() {
    Assert.notNull(INSTANCE, "No SpringInjector instance created yet. Add  <bean class=\""
            + SpringInjector.class.getName() + "\" /> to your spring configuration!");

    return INSTANCE;
}

From source file:org.mule.module.apikit.validation.io.SchemaResourceLoader.java

@Override
public Resource getResource(String location) {
    Assert.notNull(location, "Location must not be null");
    if (location.startsWith(JSON_SCHEMA_PREFIX)) {
        return new JsonSchemaResource(location.substring(JSON_SCHEMA_PREFIX.length()), getClassLoader());
    } else if (location.startsWith(XML_SCHEMA_PREFIX)) {
        return new XmlSchemaResource(location.substring(XML_SCHEMA_PREFIX.length()), getClassLoader());
    } else {//from  w w  w .  j  a  va 2 s.c om
        return super.getResource(location);
    }
}

From source file:com.athena.peacock.common.core.util.ScpUtil.java

/**
 * <pre>/*from   ww w. ja v  a 2 s .  c  om*/
 * source?  ?(? ) ? ? target .
 * </pre>
 * @param targetHost
 * @param source
 * @param target
 */
public static void upload(TargetHost targetHost, String source, String target) {

    Assert.notNull(targetHost, "targetHost cannot be null.");
    Assert.notNull(source, "source cannot be null.");
    Assert.notNull(target, "target cannot be null.");

    String destination = targetHost.getUsername() + "@" + targetHost.getHost() + ":" + target;

    logger.debug("[scp upload] " + source + " - " + destination);

    Project project = new Project();

    Scp scp = new Scp();

    // Ant Project Property
    scp.setProject(project);
    scp.setVerbose(true);

    // Set Scp properties 
    scp.setPort(targetHost.getPort());
    scp.setPassword(targetHost.getPassword());
    scp.setTodir(destination);
    scp.setTrust(targetHost.isTrust());

    // ? source  ?  FileSet? scp? .
    File filesetDir = new File(source);
    if (filesetDir.isDirectory()) {
        FileSet fileSet = new FileSet();
        fileSet.setDir(filesetDir);
        fileSet.setProject(project);

        scp.addFileset(fileSet);
    } else {
        scp.setFile(source);
    }

    if (targetHost.getKeyfile() != null) {
        scp.setKeyfile(targetHost.getKeyfile());
    }

    scp.execute();
}

From source file:com.greendot.db.dao.jpa.JpaGoodDao.java

@PersistenceContext(name = "greendot-jpa-db-test")
@Override/*from   w w  w .ja va  2  s. co m*/
public void setEntityManager(final EntityManager entityManager) {

    Assert.notNull(entityManager, "Mandatory argument 'entityManager' is missing.");
    super.setEntityManager(entityManager);
}

From source file:demo.domain.VehicleIdentificationNumber.java

public VehicleIdentificationNumber(String vin) {
    Assert.notNull(vin, "VIN must not be null");
    Assert.isTrue(vin.length() == 17, "VIN must be exactly 17 characters");
    this.vin = vin;
}

From source file:com.etrip.service.Impl.GroupServiceImpl.java

@Override
public ResultMap search(String name, Integer page, Integer rows) {
    Assert.notNull(rows, "rows is null");
    Assert.notNull(page, "page is null");
    ResultMap resultMap = new ResultMap();
    FilterMap filterMap = FilterMap.init();
    filterMap.eq("deleted", 0);
    if (StringUtils.isNotBlank(name)) {
        filterMap.like("name", "%" + name + "%");
    }//from  w w w  .  j  a  v a  2s  .  com
    OrderMap orderMap = new OrderMap();
    orderMap.desc("id");
    Page queryPage = pGroupRepository.queryPage(filterMap, orderMap, page, rows);
    int count = Integer.parseInt(queryPage.getPageInfo().get("pageCount").toString());
    int totalCount = Integer.parseInt(queryPage.getPageInfo().get("totalCount").toString());
    if (totalCount % count != 0) {
        queryPage.getPageInfo().put("totalPage", totalCount / count + 1);
    }
    resultMap.success();
    resultMap.put(queryPage);
    return resultMap;
}