Examples of MetaBean


Examples of org.apache.bval.model.MetaBean

        MetaBean mb2 = mbm.findForClass(BusinessObject.class);
        assertTrue(mb2.getProperty("lastName").isMandatory());
    }

    public void testCopy() {
        MetaBean mb = mbm.findForClass(BusinessObject.class);
        MetaBean mb2 = mb.copy();
        assertTrue(mb2 != mb);
        assertTrue(mb2.getProperty("dateBirth") != mb.getProperty("dateBirth"));
    }
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        assertTrue(mb2.getProperty("dateBirth") != mb.getProperty("dateBirth"));
    }

    public void testFindForClass() throws Exception {
        MetaBeanFinder finder = mbm;
        MetaBean info = finder.findForClass(BusinessObject.class);
        assertNotNull(info);
        assertTrue(info == info.getProperty("address").getMetaBean().getProperty("owner").getMetaBean());
        assertTrue(info == info.getProperty("addresses").getMetaBean().getProperty("owner").getMetaBean());
        assertTrue(info.getProperty("email").getJavaScriptValidations().length > 0);
    }
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        assertNotNull(all);
        Map<String, MetaBean> all2 = mbm.findAll();
        assertEquals(all.size(), all2.size());
        assertTrue(all.get(BusinessObject.class.getName()) == all2.get(BusinessObject.class.getName()));
        assertTrue(all.get(BusinessObject.class.getName()) != null);
        MetaBean bean = all.get(BusinessObject.class.getName());
        assertTrue(bean == bean.getProperty("address").getMetaBean().getProperty("owner").getMetaBean());
        assertTrue(bean == bean.getProperty("addresses").getMetaBean().getProperty("owner").getMetaBean());
    }
View Full Code Here

Examples of org.apache.bval.model.MetaBean

    public Map<String, MetaBean> enrichCopies(XMLMetaBeanInfos... infos) {
        Map<String, MetaBean> cached = findAll();
        try {
            Map<String, MetaBean> patched = ((XMLMetaBeanBuilder) builder).enrichCopies(cached, infos);
            for (Object entry : patched.values()) {
                MetaBean meta = (MetaBean) entry;
                computeRelationships(meta, patched);
            }
            return patched;
        } catch (RuntimeException e) {
            throw e; // do not wrap runtime exceptions
View Full Code Here

Examples of org.apache.bval.model.MetaBean

    public Map<String, MetaBean> findAll() {
        if (!complete) {
            try {
                Map<String, MetaBean> allBuilt = builder.buildAll();
                for (MetaBean meta : allBuilt.values()) {
                    MetaBean cached = cache.findForId(meta.getId());
                    if (cached == null) {
                        cache.cache(meta);
                    }
                }
                Map<String, MetaBean> map = cache.findAll();
                for (Object oentry : map.values()) {
                    MetaBean meta = (MetaBean) oentry;
                    computeRelationships(meta, map);
                }
                complete = true;
                return map;
            } catch (RuntimeException e) {
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        checkGroups(groups);

        try {

            Class<T> objectClass = (Class<T>) object.getClass();
            MetaBean objectMetaBean =
                factoryContext.getMetaBeanFinder().findForClass(objectClass);

            final GroupValidationContext<T> context =
                createContext(objectMetaBean, object, objectClass, groups);
            final ConstraintValidationListener<T> result =
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        checkGroups(groups);

        try {

            Class<T> objectClass = (Class<T>) object.getClass();
            MetaBean objectMetaBean =
                factoryContext.getMetaBeanFinder().findForClass(objectClass);

            GroupValidationContext<T> context =
                createContext(objectMetaBean, object, objectClass, groups);
            ConstraintValidationListener<T> result = context.getListener();
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        checkBeanType(beanType);
        checkPropertyName(propertyName);
        checkGroups(groups);

        try {
            MetaBean metaBean =
                factoryContext.getMetaBeanFinder().findForClass(beanType);
            GroupValidationContext<T> context =
                createContext(metaBean, null, beanType, groups);
            ConstraintValidationListener<T> result = context.getListener();
            context.setMetaProperty(getNestedProperty(metaBean, null,
View Full Code Here

Examples of org.apache.bval.model.MetaBean

        final AnnotationConstraintBuilder<A> builder = new AnnotationConstraintBuilder<A>(
              constraintClasses, validator, annotation, owner, access);

        // JSR-303 3.4.4: Add implicit groups
        if ( prop != null && prop.getParentMetaBean() != null ) {
            MetaBean parentMetaBean = prop.getParentMetaBean();
            // If:
            //  - the owner is an interface
            //  - the class of the metabean being build is different than the owner
            //  - and only the Default group is defined
            // Then: add the owner interface as implicit groups
            if ( builder.getConstraintValidation().getOwner().isInterface() &&
                    parentMetaBean.getBeanClass() != builder.getConstraintValidation().getOwner() &&
                    builder.getConstraintValidation().getGroups().size() == 1 &&
                    builder.getConstraintValidation().getGroups().contains(Default.class) ) {
                Set<Class<?>> groups = builder.getConstraintValidation().getGroups();
                groups.add(builder.getConstraintValidation().getOwner());
                builder.getConstraintValidation().setGroups(groups);
View Full Code Here

Examples of org.apache.bval.model.MetaBean

     * @param clazz
     * @return MetaBean
     * @throws Exception
     */
    public MetaBean buildForClass(Class<?> clazz) throws Exception {
        MetaBean meta = new MetaBean();
        if (clazz != null) { // local class here?
            meta.setBeanClass(clazz);
            meta.setId(clazz.getName()); // default id = full class name!
        }
        for (MetaBeanFactory factory : factories) {
            factory.buildMetaBean(meta);
        }
        return meta;
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.