Package com.dottydingo.hyperion.exception

Examples of com.dottydingo.hyperion.exception.BadParameterException


                return (T) Long.valueOf(argument);
            }
        }
        catch (IllegalArgumentException ex)
        {
            throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
        }

        // date
        if (type.equals(Date.class))
        {
            try
            {
                return (T) dateParser.parseDateTime(argument).toDate();
            }
            catch (IllegalArgumentException ex1)
            {
                throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
            }
        }

        // try to parse via valueOf(String s) method
        try
        {
            logger.debug("Trying to get and invoke valueOf(String s) method on {}", type);
            Method method = type.getMethod("valueOf", String.class);
            return (T) method.invoke(type, argument);

        }
        catch (NoSuchMethodException ex)
        {
            logger.warn("{} does not have method valueOf(String s)", type);
        }
        catch (Exception ex)
        {
            throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()),ex);
        }

        throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
    }
View Full Code Here

TOP

Related Classes of com.dottydingo.hyperion.exception.BadParameterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.