Package ch.nerdin.generators.testdata.framework

Examples of ch.nerdin.generators.testdata.framework.FieldProperty


        return createObject;
    }

    private Object instantiateType(Class<?> type) {
        return isComplexType(type) ? instantiateBean(type)
                : beanBuilder.instantiateValueForField(new FieldProperty(type));
    }
View Full Code Here


        return !Modifier.isFinal(type.getModifiers());
    }

    private void setFieldValues(Map<String, FieldProperty> fieldProperties, Object bean) {
        for (String name : fieldProperties.keySet()) {
            FieldProperty fieldProperty = fieldProperties.get(name);
            Object value = instantiateValueForField(fieldProperty);
            setFieldValue(bean, fieldProperty.getType(), name, value);
        }
    }
View Full Code Here

*/
public class JpaInspector extends AbstractInspector {

    @Override
    void createFieldProperties(String fieldName, Annotation annotation) {
        FieldProperty property = fieldContext.getFieldProperty(fieldName);
        Class<? extends Annotation> annotationType = annotation.annotationType();

        if (annotationType.equals(Column.class)) {
            Column column = (Column) annotation;
            property.setMaxLength(column.length());
            property.setMinLength(column.length());
        }
       
        if (annotationType.equals(Lob.class)) {
            property.setLob(true);
        }
    }
View Full Code Here

    private final static String CREDIT_CARD_REGEX = "5[1-5][0-9]{14}";
    private final static String DIGITS_REGEX = "[0-9]*";

    @Override
    void createFieldProperties(String field, Annotation annotation) {
        FieldProperty property = fieldContext.getFieldProperty(field);
        Class<? extends Annotation> annotationType = annotation.annotationType();

        if (annotationType.equals(Length.class)) {
            Length length = (Length) annotation;
            property.setMaxLength(length.max());
            property.setMinLength(length.min());
        }
        if (annotationType.equals(Range.class)) {
            Range length = (Range) annotation;
            property.setMaxLength(length.max());
            property.setMinLength(length.min());
        }
        if (annotationType.equals(Min.class)) {
            Min min = (Min) annotation;
            property.setMinLength(min.value());
        }
        if (annotationType.equals(Max.class)) {
            Max max = (Max) annotation;
            property.setMaxLength(max.value());
        }
        if (annotationType.equals(Pattern.class)) {
            Pattern pattern = (Pattern) annotation;
            property.setRegex(pattern.regex());
        }
        if (annotationType.equals(Email.class)) {
            property.setRegex(EMAIL_REGEX);
        }
        if (annotationType.equals(CreditCardNumber.class)) {
            property.setRegex(CREDIT_CARD_REGEX);
        }
        if (annotationType.equals(Digits.class)) {
            property.setRegex(DIGITS_REGEX);
        }
        if (annotationType.equals(Past.class)) {
            property.setPast(true);
        }
        if (annotationType.equals(Future.class)) {
            property.setFuture(true);
        }
    }
View Full Code Here

        this.inspectedFields = inspectedFields;
        this.inspectClass = inspectClass;
    }

    public FieldProperty getFieldProperty(String field) {
        FieldProperty property = inspectedFields.get(field);
        if (property == null) {
            property = new FieldProperty();
            inspectedFields.put(field, property);
        }
        return property;
    }
View Full Code Here

TOP

Related Classes of ch.nerdin.generators.testdata.framework.FieldProperty

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.