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.flipkart.aesop.elasticsearchdatalayer.config.ElasticSearchConfig.java

@Override
public void afterPropertiesSet() throws Exception {
    /* Assert if filename is ot empty */
    Assert.notNull(this.config,
            "'ElasticSearchConfig' cannot be null. This Databus Client will not be initialized");
}

From source file:net.easysmarthouse.service.context.ProxiedResolverGenericXmlApplicationContext.java

@Override
public <T extends Object> T getBean(Class<T> requiredType) throws BeansException {
    Assert.notNull(requiredType, "Required type must not be null");
    String[] beanNames = getBeanNamesForType(requiredType);
    String primaryCandidate = null;

    if (beanNames.length > 1) {
        ArrayList<String> autowireCandidates = new ArrayList<String>();

        for (String beanName : beanNames) {
            BeanDefinition beanDefinition = getBeanDefinition(beanName);
            if (beanDefinition.isAutowireCandidate()) {
                autowireCandidates.add(beanName);
                if (beanDefinition.isPrimary()) {
                    primaryCandidate = beanName;
                }//  ww  w.  j  a v  a2 s  .  c  o m
            }
        }

        for (String autowireCandidate : autowireCandidates) {
            if (autowireCandidates.contains(autowireCandidate + "Proxied")) {
                primaryCandidate = autowireCandidate;
            }
        }

        if (autowireCandidates.size() > 0) {
            beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
        }
    }

    if (beanNames.length == 1) {
        return getBean(beanNames[0], requiredType);

    } else if (beanNames.length > 1) {
        // more than one bean defined, lookup primary candidate
        if (primaryCandidate != null) {
            return getBean(primaryCandidate, requiredType);
        }
        throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found "
                + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames));

    } else if (beanNames.length == 0 && getParentBeanFactory() != null) {
        return getParentBeanFactory().getBean(requiredType);

    } else {
        throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found "
                + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames));

    }
}

From source file:io.curly.artifact.model.ArtifactReqBody.java

public Artifact toArtifact(User user) {
    Assert.notNull(user, "User must be not null!");
    return new Artifact(this.id, this.author, this.name, this.homePage, this.githubPage, this.description,
            this.languages, this.tags, this.category, this.incubation, user.getId());
}

From source file:io.pivotal.poc.claimcheck.LocalFileClaimCheckStore.java

public LocalFileClaimCheckStore(File directory, IdGenerator idGenerator) {
    Assert.notNull(directory, "directory must not be null");
    Assert.notNull(idGenerator, "IdGenerator must not be null");
    if (directory.exists()) {
        Assert.isTrue(directory.isDirectory());
    } else {//from   w w w . ja  va  2 s  .  c  o  m
        directory.mkdirs();
    }
    this.directory = directory;
    this.idGenerator = idGenerator;
}

From source file:org.cleverbus.core.common.contextcall.ContextCallParams.java

public ContextCallParams(Class<?> targetType, String methodName, Object... methodArgs) {
    Assert.notNull(targetType, "the targetType must not be null");
    Assert.hasText(methodName, "the methodName must be defined");

    this.targetType = targetType;
    this.methodName = methodName;
    this.methodArgs = new ArrayList<Object>(Arrays.asList(methodArgs));
    this.creationTimestamp = DateTime.now();
}

From source file:org.springmodules.validation.util.cel.ognl.OgnlCondition.java

/**
 * Constructs a new OgnlCondition with given OGNL boolean expression.
 *
 * @param expression The given OGNL boolean expression.
 *///  www  .ja v a 2s .  com
public OgnlCondition(String expression) {
    Assert.notNull(expression, "OGNL expression cannot be null");
    this.expression = expression;
    try {
        compiledExpression = Ognl.parseExpression(expression);
    } catch (OgnlException oe) {
        throw new NestedIllegalArgumentException("Could not parse OGNL boolean expression '" + expression + "'",
                oe);
    }
}

From source file:com.excilys.ebi.bank.service.impl.security.SimpleAccessControlEntryImpl.java

public SimpleAccessControlEntryImpl(Acl acl, Sid sid, Permission permission, boolean granting) {
    Assert.notNull(acl, "Acl required");
    Assert.notNull(sid, "Sid required");
    Assert.notNull(permission, "Permission required");
    this.acl = acl; // can be null
    this.sid = sid;
    this.permission = permission;
    this.granting = granting;
}

From source file:com.buession.cas.web.utils.CaptchaUtils.java

/**
 * ??? Cookie/* w ww .  j  a v a2s.com*/
 * 
 * @param config
 * @return
 */
public final static String getCaptchaCookieName(final Config config) {
    Assert.notNull(config, "Captcha config could not be null");

    String name = config.getSessionKey();
    return name == null ? VALIDATE_CODE : name;
}

From source file:com.autentia.wuija.widget.notification.EventProcessor.java

/**
 * Aade un nuevo listener para procesar eventos.
 * /*from  ww  w  .j  a  v  a 2  s . c om*/
 * @param widgetListener el listener que se quiere aadir.
 */
public void addListener(WidgetListener widgetListener) {
    Assert.notNull(widgetListener, "widgetListener cannot be null");
    listeners.add(widgetListener);
}

From source file:com.wavemaker.commons.io.ResourcePath.java

/**
 * Private constructor used to create a nested path.
 * //from  w w  w.  j  av  a2  s . c  o  m
 * @param parent the parent
 * @param name the name of the path element
 * @see #get(String)
 */
private ResourcePath(ResourcePath parent, String name) {
    Assert.notNull(name, "Name must not be null");
    this.parent = parent;
    this.name = name;
}