Examples of AchillesBeanMappingException


Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        }
    }

    public static void validateBeanMappingNotNull(Object arg, String message, Object... args) {
        if (arg == null) {
            throw new AchillesBeanMappingException(format(message, args));
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        String canonicalName = arg.getCanonicalName();

        try {
            instantiator.instantiate(arg);
        } catch (NoClassDefFoundError | InstantiationError e) {
            throw new AchillesBeanMappingException(
                    format("Cannot instantiate the class '%s'. Please ensure the class is not an abstract class, an interface, an array class, a primitive type, or void and have a nullary (default) constructor and is declared public",
                            canonicalName));
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        }
    }

    public static void validateBeanMappingTrue(boolean condition, String message, Object... args) {
        if (!condition) {
            throw new AchillesBeanMappingException(format(message, args));
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        }
    }

    public static void validateBeanMappingFalse(boolean condition, String message, Object... args) {
        if (condition) {
            throw new AchillesBeanMappingException(format(message, args));
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

    private Codec<?,?> validateInstantiable(Field field, Class<?> codecClass) {
        try {
            return (Codec<?,?>)codecClass.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new AchillesBeanMappingException(format("Codec class '%s' declared on the field '%s' of class '%s' should be instantiable (declare a public constructor)",
                    codecClass.getCanonicalName(), field.getName(), field.getDeclaringClass().getCanonicalName()));
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        log.debug("Validate parameterized types for property {} of entity class {}", field.getName(),
                entityClass.getCanonicalName());

        Type genericType = field.getGenericType();
        if (!(genericType instanceof ParameterizedType)) {
            throw new AchillesBeanMappingException("The Map type should be parameterized for the entity '"
                    + entityClass.getCanonicalName() + "'");
        } else {
            ParameterizedType pt = (ParameterizedType) genericType;
            Type[] actualTypeArguments = pt.getActualTypeArguments();
            if (actualTypeArguments.length <= 1) {
                throw new AchillesBeanMappingException(
                        "The Map type should be parameterized with <K,V> for the entity '"
                                + entityClass.getCanonicalName() + "'");
            }
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

            Pair<ConsistencyLevel, ConsistencyLevel> consistencyLevels) {
        log.debug("Validate that counter property {} of entity class {} does not have ANY consistency level",
                context.getCurrentPropertyName(), context.getCurrentEntityClass().getCanonicalName());

        if (consistencyLevels.left == ANY || consistencyLevels.right == ANY) {
            throw new AchillesBeanMappingException(
                    "Counter field '"
                            + context.getCurrentField().getName()
                            + "' of entity '"
                            + context.getCurrentEntityClass().getCanonicalName()
                            + "' cannot have ANY as read/write consistency level. All consistency levels except ANY are allowed");
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

    }

    public static void validateAllowedTypes(Class<?> type, Set<Class<?>> allowedTypes, String message) {
        log.debug("Validate that type {} is supported", type);
        if (!allowedTypes.contains(type) && !type.isEnum()) {
            throw new AchillesBeanMappingException(message);
        }
    }
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        for (String getter : getters) {
            try {
                getterMethod = beanClass.getMethod(getter);
                if (getterMethod.getReturnType() != field.getType()) {
                    throw new AchillesBeanMappingException("The getter for field '" + fieldName + "' of type '"
                            + field.getDeclaringClass().getCanonicalName() + "' does not return correct type");
                }
            } catch (NoSuchMethodException e) {
                // Do nothing here
            }
        }
        if (getterMethod == null) {
            throw new AchillesBeanMappingException("The getter for field '" + fieldName + "' of type '"
                    + field.getDeclaringClass().getCanonicalName() + "' does not exist");
        }

        log.trace("Derived getter method : {}", getterMethod.getName());
        return getterMethod;
View Full Code Here

Examples of info.archinnov.achilles.exception.AchillesBeanMappingException

        try {
            String setter = this.deriveSetterName(field);
            Method setterMethod = beanClass.getMethod(setter, field.getType());

            if (!setterMethod.getReturnType().toString().equals("void")) {
                throw new AchillesBeanMappingException("The setter for field '" + fieldName + "' of type '"
                        + field.getDeclaringClass().getCanonicalName()
                        + "' does not return correct type or does not have the correct parameter");
            }

            log.trace("Derived setter method : {}", setterMethod.getName());
            return setterMethod;

        } catch (NoSuchMethodException e) {
            throw new AchillesBeanMappingException("The setter for field '" + fieldName + "' of type '"
                    + field.getDeclaringClass().getCanonicalName() + "' does not exist or is incorrect");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.