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:fr.mby.portal.coreimpl.event.BasicEvent.java

/** Protected constructor. Use the factory. */
protected BasicEvent(final String name, final Serializable value) {
    super();//  w w  w.  j  a v a  2 s .co  m

    Assert.notNull(name, "No name provided !");
    Assert.notNull(value, "No value provided !");

    this.name = name;
    this.value = value;
}

From source file:de.itsvs.cwtrpc.core.pattern.PatternFactory.java

public static Pattern compile(PatternType patternType, MatcherType matcherType, String pattern)
        throws IllegalArgumentException {
    final PatternMatcher<?> matcher;

    Assert.notNull(patternType, "'patternType' must not be null");
    Assert.notNull(matcherType, "'matcherType' must not be null");

    if (patternType == PatternType.REGEX) {
        matcher = regexAntPatternMatcher;
    } else if (patternType == PatternType.ANT) {
        switch (matcherType) {
        case URI:
            matcher = uriAntPatternMatcher;
            break;
        case PACKAGE:
            matcher = packageAntPatternMatcher;
            break;
        default:/*from  w w w.jav  a 2 s  . com*/
            throw new IllegalStateException("Unhandled matcher type: " + matcherType);
        }
    } else {
        throw new IllegalStateException("Unhandled pattern type: " + patternType);
    }

    return DefaultPattern.createDefaultPattern(matcher, pattern);
}

From source file:com.framework.infrastructure.utils.HibernateUtils.java

/**
 * ID,./*from w ww .  j a  v  a  2  s. c  o  m*/
 * 
 * id,id.
 * id,id. ID,
 * cascade-save-or-update.
 * 
 * @param srcObjects
 *            ,.
 * @param checkedIds
 *            ,ID.
 * @param clazz
 *            
 * @param idName
 *            
 */
public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds,
        final Class<T> clazz, final String idName) {

    // 
    Assert.notNull(srcObjects, "scrObjects");
    Assert.hasText(idName, "idName");
    Assert.notNull(clazz, "clazz");

    // , .
    if (checkedIds == null) {
        srcObjects.clear();
        return;
    }

    // ,idID,.
    // ,id,idid.
    Iterator<T> srcIterator = srcObjects.iterator();
    try {

        while (srcIterator.hasNext()) {
            T element = srcIterator.next();
            Object id;
            id = PropertyUtils.getProperty(element, idName);

            if (!checkedIds.contains(id)) {
                srcIterator.remove();
            } else {
                checkedIds.remove(id);
            }
        }

        // IDid,,id.
        for (ID id : checkedIds) {
            T obj = clazz.newInstance();
            PropertyUtils.setProperty(obj, idName, id);
            srcObjects.add(obj);
        }
    } catch (Exception e) {
        throw ReflectionUtils.convertReflectionExceptionToUnchecked(e);
    }
}

From source file:doge.domain.DogePhoto.java

public DogePhoto(User user, String fileRef) {
    Assert.notNull(user, "User must not be null");
    Assert.notNull(fileRef, "FileRef must not be null");
    this.user = user;
    this.fileRef = fileRef;
}

From source file:example.caching.SimpleBookRepository.java

public SimpleBookRepository(Map<Long, Book> content) {

    Assert.notNull(content, "Source map must not be null!");
    this.content = new ConcurrentHashMap<Long, Book>(content);
}

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

@Nonnull
public static final Mapper.Option writeConsistencyLevel(@Nonnull final Environment env) {
    Assert.notNull(env, "An environment must be given!");
    if (OptionProvider.CACHED_OPTIONS.isEmpty()) {
        OptionProvider.lazyOptionInit(env);
    }//from  w ww  . j  a v a 2 s. c  o m
    return OptionProvider.CACHED_OPTIONS.get(CassandraConnectorConstants.CONSISTENCY_LEVEL_WRITE_PROP);
}

From source file:com.acc.expressupdate.populators.ProductExpressUpdateElementPopulator.java

@Override
public void populate(final ProductModel source, final ProductExpressUpdateElementData target)
        throws ConversionException {
    Assert.notNull(source, "Parameter source cannot be null.");
    Assert.notNull(target, "Parameter target cannot be null.");

    target.setCode(source.getCode());/*from   w  w w  . j  a va 2s.  co  m*/
    if (source.getCatalogVersion() != null) {
        target.setCatalogVersion(source.getCatalogVersion().getVersion());
        if (source.getCatalogVersion().getCatalog() != null) {
            target.setCatalogId(source.getCatalogVersion().getCatalog().getId());
        }
    }
}

From source file:example.app.model.Address.java

public static Address newAddress(Point location) {
    Assert.notNull(location, "location is required");

    Address address = new Address();

    address.setLocation(location);//  ww w.j av a2 s.  co  m

    return address;
}

From source file:org.codehaus.groovy.grails.scaffolding.SimpleDomainClassPropertyComparator.java

public SimpleDomainClassPropertyComparator(GrailsDomainClass domainClass) {
    Assert.notNull(domainClass, "Argument 'domainClass' is required!");
    this.domainClass = domainClass;
}

From source file:org.vertx.mods.examples.beans.AbstractEcho.java

protected void register(String address) throws Exception {
    Assert.notNull(vertx, "Vertx must not be null");

    this.handlerId = vertx.eventBus().registerHandler(address, new Handler<Message<String>>() {

        @Override/*from   ww w .j a v  a2 s. c om*/
        public void handle(Message<String> event) {
            event.reply(event.body);
        }
    });
}