Package com.blogspot.mydailyjava.dp.handler

Examples of com.blogspot.mydailyjava.dp.handler.TransformationException


            return new MethodDecoder(type.getDeclaredMethod(VALUE_OF_METHOD_NAME, String.class));
        } catch (NoSuchMethodException ignore) {
            try {
                return new ConstructorDecoder(type.getDeclaredConstructor(String.class));
            } catch (NoSuchMethodException e) {
                throw new TransformationException(String.format("%s is not a non-abstract type with a single String " +
                        "constructor or has a static valueOf(String) method", type));
            }
        }
    }
View Full Code Here


        @Override
        public Object decode(String raw) throws IllegalAccessException {
            try {
                return constructor.newInstance(raw);
            } catch (InstantiationException e) {
                throw new TransformationException(String.format("Could not instantiate %s", constructor), e);
            } catch (InvocationTargetException e) {
                throw new TransformationException(String.format("Error on instantiating %s with %s", constructor, raw), e.getCause());
            }
        }
View Full Code Here

    }

    @Override
    public void setValue(Object bean, String raw) throws IllegalAccessException {
        if (raw.length() != 1) {
            throw new TransformationException(String.format("Could not set %s as a single char property for %s", raw, getField()));
        }
        getField().setChar(bean, raw.charAt(0));
    }
View Full Code Here

TOP

Related Classes of com.blogspot.mydailyjava.dp.handler.TransformationException

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.