Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param condition/*from   ww w  .  j a  v  a2  s  .  co  m*/
 * @param message
 */
public static void validateIsFalse(final boolean condition, final String message) {
    try {
        isTrue(!condition, message);
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:com.googlecode.jsendnsca.NagiosSettingsFactory.java

private static void toPort(NagiosSettings settings, String name, String value)
        throws NagiosConfigurationException {
    try {//from w ww .  j  a  v a2 s. co  m
        settings.setPort(toInteger(name, value));
    } catch (IllegalArgumentException e) {
        throw new NagiosConfigurationException("Key [%s] %s, was [%s]", name, e.getMessage(), value);
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName//from  w  w w  .  ja  v a2s . c o  m
 * @param value
 * @param minValue
 * @param maxValue
 */
public static void validateInRange(final String entityName, final int value, final int minValue,
        final int maxValue) {
    try {
        isTrue((value >= minValue) && (value <= maxValue), notInRange(entityName, value, minValue, maxValue));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName/*  w w w  .  j  a v a 2 s .com*/
 * @param value
 * @param minValue
 * @param maxValue
 */
public static void validateInRange(final String entityName, final double value, final double minValue,
        final double maxValue) {
    try {
        isTrue((value >= minValue) && (value <= maxValue), notInRange(entityName, value, minValue, maxValue));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * A useful check for {@link Comparable#compareTo(Object)} methods.
 * //from w  w  w  .j a  va 2  s  .c  o m
 * @param object1
 * @param object2
 */
public static void validateEqualClass(final Object object1, final Object object2) {
    try {
        if ((object1 != object2) && (object1.getClass() != object2.getClass())) {
            throw new ClassCastException(cannotCompareMessage(object1.getClass(), object2.getClass()));
        }
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * A useful check for {@link Comparable#compareTo(Object)} methods.
 * /*from w  w w .j a v a  2  s  . c  om*/
 * @param object
 * @param type
 */
public static void validateInstanceOf(final Object object, final Class<?> type) {
    try {
        if (!ReflectionUtil.instanceOf(object, type)) {
            throw new ClassCastException(cannotCompareMessage(type, object.getClass()));
        }
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:com.evolveum.midpoint.util.ReflectionUtil.java

public static Object invokeMethod(Object object, String methodName, List<?> argList)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    Method method = findMethod(object, methodName, argList);
    if (method == null) {
        throw new NoSuchMethodException(
                "No method " + methodName + " for arguments " + debugDumpArgList(argList) + " in " + object);
    }/*w ww. ja va 2  s .  co m*/
    Object[] args = argList.toArray();
    if (method.isVarArgs()) {
        Class<?> parameterTypeClass = method.getParameterTypes()[0];
        Object[] varArgs = (Object[]) Array.newInstance(parameterTypeClass.getComponentType(), args.length);
        for (int i = 0; i < args.length; i++) {
            varArgs[i] = args[i];
        }
        args = new Object[] { varArgs };
    }
    try {
        return method.invoke(object, args);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
                e.getMessage() + " for arguments " + debugDumpArgList(argList) + " in " + object, e);
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param severity/*  ww  w . ja v a 2 s .  c  om*/
 * @param entityName
 * @param object
 */
public static void validateNotNull(final Severity severity, final String entityName, final Object object) {
    try {
        notNull(object, notNullMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(severity, e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param severity//from   w w  w  . j  a  va 2 s .c  om
 * @param condition
 * @param message
 */
public static void validateIsTrue(final Severity severity, final boolean condition, final String message) {
    try {
        isTrue(condition, message);
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(severity, e.getMessage());
    }
}

From source file:net.ripe.rpki.validator.util.TrustAnchorLocator.java

public static TrustAnchorLocator fromFile(File file) throws TrustAnchorExtractorException {
    try {//  www  . j  a  v  a  2  s.c  o  m
        String contents = Files.toString(file, Charsets.UTF_8);
        if (contents.trim().startsWith("rsync://")) {
            return readStandardTrustAnchorLocator(file, contents);
        } else {
            return readExtendedTrustAnchorLocator(file, contents);
        }
    } catch (IllegalArgumentException e) {
        throw new TrustAnchorExtractorException(
                "failed to load trust anchor locator " + file + ": " + e.getMessage(), e);
    } catch (IOException e) {
        throw new TrustAnchorExtractorException(
                "failed to open trust anchor locator " + file + ": " + e.getMessage(), e);
    } catch (URISyntaxException e) {
        throw new TrustAnchorExtractorException(
                "failed to load trust anchor locator " + file + ": " + e.getMessage(), e);
    }
}