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.azaptree.services.security.SubjectAuthenticationToken.java

public SubjectAuthenticationToken(final UUID subjectId, final Map<String, Object> credentials,
        final boolean rememberMe) {
    Assert.notNull(subjectId, "subjectId is required");
    Assert.isTrue(!CollectionUtils.isEmpty(credentials));
    this.subjectId = subjectId;
    this.credentials = credentials;
    this.rememberMe = rememberMe;
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceModuleConfig.java

public void setServiceGroupConfig(RemoteServiceGroupConfig serviceGroupConfig) {
    Assert.notNull(serviceGroupConfig, "'serviceGroupConfig' must not be null");
    this.serviceGroupConfig = serviceGroupConfig;
}

From source file:fr.mby.utils.spring.beans.factory.ProxywiredField.java

protected ProxywiredField(final DependencyDescriptor descriptor, final String wiredClassName) {
    super();//from www. j  a  v  a 2  s  .  c o m

    Assert.notNull(descriptor, "No DependencyDescriptor provided !");
    final Field field = descriptor.getField();
    Assert.notNull(field, "DependencyDescriptor provided don't describe a Field !");
    final String fieldName = field.getName();

    Assert.hasText(wiredClassName, "Wired class name cannot be found !");

    this.buildNodePath(wiredClassName, fieldName);
}

From source file:gov.nih.nci.cabig.ctms.acegi.acls.dao.impl.EhCacheBasedAclCache.java

public void evictFromCache(Serializable pk) {
    Assert.notNull(pk, "Primary key (identifier) required");

    MutableAcl acl = getFromCache(pk);/*  w w  w.jav a 2s.  c  om*/

    if (acl != null) {
        cache.remove(acl.getId());
        cache.remove(acl.getObjectIdentity());
    }
}

From source file:xolpoc.core.ModuleRunner.java

public ModuleRunner(ModuleRegistry registry, ModuleDeployer deployer, String input, String output) {
    Assert.notNull(registry, "ModuleRegistry must not be null");
    Assert.notNull(deployer, "ModuleDeployer must not be null");
    this.input = input;
    this.output = output;
    this.registry = registry;
    this.deployer = deployer;
}

From source file:org.cleverbus.core.alerts.AbstractAlertsConfiguration.java

protected final void addAlert(AlertInfo alertInfo) {
    Assert.notNull(alertInfo, "alertInfo must not be null");

    // check uniqueness
    if (alerts.contains(alertInfo)) {
        throw new IllegalStateException(
                "Wrong alert's configuration - alert (id = '" + alertInfo.getId() + "') already exist.");
    } else {// w  w w .  ja  v a2 s .c om
        Log.debug("New alert info added: " + alertInfo);
        alerts.add(alertInfo);
    }
}

From source file:org.kmnet.com.fw.common.message.ResultMessageUtils.java

/**
 * resolve message text of <code>ResultMessage</code><br>
 * <ol>//from  ww  w. j  av  a  2s. c om
 * <li>if <code>ResultMessage</code> has message code, try to resolve message using it
 * <ol>
 * <li>if there is no message for that code, try to use text of <code>ResultMessage</code>.</li>
 * <li>if there is no text, throw {@link NoSuchMessageException}</li>
 * </ol>
 * </li>
 * <li>return text of <code>ResultMessage</code> even if it is <code>null</code></li>
 * </ol>
 * @param message result message to resolve (must not be <code>null</code>)
 * @param messageSource message source (must not be <code>null</code>)
 * @param locale locate to resolve message (must not be <code>null</code>)
 * @return message text (must not be <code>null</code>)
 * @throws NoSuchMessageException if message is not found and no default text is given
 * @throws IllegalArgumentException if message or messageSoruce or locale is <code>null</code>
 */
public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale)
        throws NoSuchMessageException {

    Assert.notNull(messageSource, "messageSource must not be null!");
    Assert.notNull(message, "message must not be null!");
    Assert.notNull(locale, "locale must not be null!");

    String msg = null;
    String code = message.getCode();
    if (code != null) {
        // try to resolve from code at first.
        try {
            msg = messageSource.getMessage(code, message.getArgs(), locale);
        } catch (NoSuchMessageException e) {
            String text = message.getText();
            if (text != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '"
                            + text + "' instead", e);
                }
                // if ResultMessage has a text, then use it.
                msg = text;
            } else {
                // otherwise throw exception
                throw e;
            }
        }
    } else {
        msg = message.getText();
    }
    return msg;
}

From source file:org.terasoluna.gfw.common.message.ResultMessageUtils.java

/**
 * resolve message text of <code>ResultMessage</code><br>
 * <ol>/*from  w  w  w  . j av a 2 s  .c om*/
 * <li>if <code>ResultMessage</code> has message code, try to resolve message using it
 * <ol>
 * <li>if there is no message for that code, try to use text of <code>ResultMessage</code>.</li>
 * <li>if there is no text, throw {@link NoSuchMessageException}</li>
 * </ol>
 * </li>
 * <li>return text of <code>ResultMessage</code> even if it is <code>null</code></li>
 * </ol>
 * @param message result message to resolve (must not be <code>null</code>)
 * @param messageSource message source (must not be <code>null</code>)
 * @param locale locate to resolve message (must not be <code>null</code>)
 * @return message text (must not be <code>null</code>)
 * @throws NoSuchMessageException if message is not found and no default text is given
 * @throws IllegalArgumentException if message or messageSoruce or locale is <code>null</code>
 */
public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale)
        throws NoSuchMessageException {
    Assert.notNull(messageSource, "messageSource must not be null!");
    Assert.notNull(message, "message must not be null!");
    Assert.notNull(locale, "locale must not be null!");

    String msg;
    String code = message.getCode();
    if (code != null) {
        // try to resolve from code at first.
        try {
            msg = messageSource.getMessage(code, message.getArgs(), locale);
        } catch (NoSuchMessageException e) {
            String text = message.getText();
            if (text != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '"
                            + text + "' instead", e);
                }
                // if ResultMessage has a text, then use it.
                msg = text;
            } else {
                // otherwise throw exception
                throw e;
            }
        }
    } else {
        msg = message.getText();
    }
    return msg;
}

From source file:org.lightadmin.core.util.NumberUtils.java

@SuppressWarnings("unchecked")
public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass)
        throws IllegalArgumentException {
    Assert.notNull(number, "Number must not be null");
    Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return (T) number;
    } else if (targetClass.equals(byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }// w ww  .  j  av a2s .com
        return (T) new Byte(number.byteValue());
    } else if (targetClass.equals(short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Short(number.shortValue());
    } else if (targetClass.equals(int.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Integer(number.intValue());
    } else if (targetClass.equals(long.class)) {
        return (T) new Long(number.longValue());
    } else if (targetClass.equals(float.class)) {
        return (T) Float.valueOf(number.toString());
    } else if (targetClass.equals(double.class)) {
        return (T) Double.valueOf(number.toString());
    } else {
        return org.springframework.util.NumberUtils.convertNumberToTargetClass(number, targetClass);
    }
}

From source file:de.itsvs.cwtrpc.security.RpcAuthenticationEntryPoint.java

public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
    Assert.notNull(redirectStrategy, "'redirectStrategy' must not be null");
    this.redirectStrategy = redirectStrategy;
}