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.trenako.services.view.ItemView.java

/**
 * Creates a new item view for a {@code WishList} item.
 *
 * @param collection the rolling stocks wish list
 * @param item       the wish list item/*w  ww.j a  v  a2s . c o m*/
 * @return a {@code ItemView}
 */
public static ItemView createView(WishList wishList, WishListItem item) {
    Assert.notNull(item.getRollingStock(), "Item rolling stock is required");

    return new ItemView(wishList.getSlug(), wishList.getName(), item.getRollingStock().getSlug(),
            item.getRollingStock().getLabel(), item.getAddedAt());
}

From source file:com.ximalaya.shardis.ShardRedisAccessor.java

public void afterPropertiesSet() {
    Assert.notNull(getConnectionFactory(), "ShardRedisConnectionFactory is required");
}

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

@Override
public void changeCurrentEtablissement(final String userId, final Etablissement etab) {
    Assert.hasText(userId, "No user Id supplied !");
    Assert.notNull(etab, "No etablishement supplied !");

    this.userDao.saveCurrentEtablissement(userId, etab.getId());
}

From source file:slina.mb.smb.DefaultSmbSessionFactory.java

@Override
public Session getSession() {
    Assert.notNull(this.domain, "domain must not be null");
    Assert.hasText(this.user, "user must not be empty");
    Assert.isTrue(StringUtils.hasText(this.password), "password is required");
    try {// w w w . j  a  v a2s .  c o m
        NtlmPasswordAuthentication ntlmAuth = new NtlmPasswordAuthentication(domain, user, password);
        Session smbSession = new SmbSessionImpl(ntlmAuth);
        return smbSession;
    } catch (Exception e) {
        throw new IllegalStateException("failed to create SMB Session", e);
    }
}

From source file:com.athena.chameleon.common.utils.ZipUtil.java

/**
 * <pre>/*from w  ww.j  a v a 2  s  .  c  o  m*/
 * ?  ? ? .
 * </pre>
 * @param baseDir
 * @param destFile
 * @param type
 * @return
 * @throws IOException
 * @throws ManifestException 
 */
public static boolean compress(String baseDir, String destFile, ArchiveType type)
        throws IOException, ManifestException {
    Assert.notNull(baseDir, "baseDir cannot be null.");

    Project project = new Project();

    File filesetDir = new File(baseDir);
    File archiveFile = null;

    Assert.isTrue(filesetDir.exists(), baseDir + " does not exist.");
    Assert.isTrue(filesetDir.isDirectory(), baseDir + " is not a directory.");

    if (StringUtils.isEmpty(destFile)) {
        archiveFile = new File(filesetDir.getParent(),
                new StringBuilder(filesetDir.getName()).append(".").append(type.value()).toString());
    } else {
        archiveFile = new File(destFile);
    }

    FileSet fileSet = new FileSet();
    fileSet.setDir(filesetDir);
    fileSet.setProject(project); // project ?  DirectoryScanner  ?  Excption? ?.

    Zip zip = new Zip();
    zip.setProject(project); // project ?  destFile   Exception ?.
    zip.setDestfile(archiveFile);
    zip.add(fileSet);

    zip.execute();

    return true;
}

From source file:com.oreilly.springdata.gemfire.order.LineItem.java

/**
 * Creates a new {@link LineItem} for the given {@link Product} and amount.
 * @param product must not be {@literal null}.
 * @param amount/*w ww .j  a  v  a2 s.  c om*/
 */
public LineItem(Product product, int amount) {
    Assert.notNull(product, "The given Product must not be null!");
    Assert.isTrue(amount > 0, "The amount of Products to be bought must be greater than 0!");

    this.productId = product.getId();
    this.amount = amount;
    this.price = product.getPrice();
}

From source file:com.autentia.wuija.widget.EditEntity.java

public void setEntity(T entity) {
    Assert.notNull(entity, "entity cannot be null");
    this.entity = entity;
}

From source file:biz.c24.io.spring.integration.transformer.C24XPathTransformer.java

public C24XPathTransformer(String statement) {
    Assert.notNull(statement, "The XPath statement must not be null.");

    this.statement = new XPathStatement(statement);
}

From source file:org.opencredo.cloud.storage.si.transformer.AbstractBlobTransformer.java

/**
 * @param template/*from w  w  w . j  av  a2s . c o m*/
 * @param deleteBlob
 */
public AbstractBlobTransformer(StorageOperations template, boolean deleteBlob) {
    super();
    Assert.notNull(template, "Template must be specified");
    this.template = template;
    this.deleteBlob = deleteBlob;
}

From source file:org.spring.data.gemfire.app.dao.vendor.SQLFireHibernateUserDao.java

protected Session preProcess(final Session session) {
    Assert.notNull(session, "The Hibernate Session must not be null!");
    Assert.state(session.isOpen(), "The Session is closed!");

    if (session instanceof SessionImpl) {
        System.out.printf("The Hibernate Session is a SessionImpl!%n");
        try {/*from  w  w  w .j av  a  2s .c o  m*/
            Assert.state(!((SessionImpl) session).connection().isClosed(),
                    "The Hibernate Session's Connection is closed!");
            //((SessionImpl) session).connection().setAutoCommit(false); // NOTE not required for SQLFire
            ((SessionImpl) session).connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
        } catch (SQLException e) {
            System.err.printf("Failed to set 'autoCommit' and 'Isolation-level' on Connection!%n%1$s%n", e);
        }
    }

    return session;
}