Package org.apache.bval.model

Examples of org.apache.bval.model.MetaBean


    private void validateCascadedBean(final GroupValidationContext<?> context, final MetaProperty prop, final Groups groups) {
        AccessStrategy[] access = prop.getFeature(Features.Property.REF_CASCADE);
        if (access != null) { // different accesses to relation
            // save old values from context
            final Object bean = context.getBean();
            final MetaBean mbean = context.getMetaBean();
            // TODO implement Validation.groups support on related bean
//            Class[] groups = prop.getFeature(JsrFeatures.Property.REF_GROUPS);
            for (final AccessStrategy each : access) {
                if (isCascadable(context, prop, each)) {
                    // modify context state for relationship-target bean
View Full Code Here


        assert (object == null) ^ (value == VALIDATE_PROPERTY);
        checkPropertyName(propertyName);
        checkGroups(groups);

        try {
            final MetaBean initialMetaBean = new DynamicMetaBean(metaBeanFinder);
            initialMetaBean.setBeanClass(beanType);
            GroupValidationContext<T> context = createContext(initialMetaBean, object, beanType, groups);
            ValidationContextTraversal contextTraversal = createValidationContextTraversal(context);
            PathNavigation.navigate(propertyName, contextTraversal);

            MetaProperty prop = context.getMetaProperty();
View Full Code Here

        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

   * @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

  /**
   * {@inheritDoc}
   */
  public MetaBean findForId(String beanInfoId) {
    MetaBean beanInfo = cache.findForId(beanInfoId);
    if (beanInfo != null) return beanInfo;
    try {
      beanInfo = builder.buildForId(beanInfoId);
      cache.cache(beanInfo);
      computeRelationships(beanInfo);
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public MetaBean findForClass(Class<?> clazz) {
    if (clazz == null) return null;
    MetaBean beanInfo = cache.findForClass(clazz);
    if (beanInfo != null) return beanInfo;
    try {
      beanInfo = builder.buildForClass(clazz);
      cache.cache(beanInfo);
      computeRelationships(beanInfo);
View Full Code Here

          if (xmlInfos.getBeans() == null) return; // empty file, ignore
          XMLMetaBeanFactory.XMLResult carrier =
              new XMLMetaBeanFactory.XMLResult(null, xmlInfos);

          for (XMLMetaBean xmlMeta : xmlInfos.getBeans()) {
            MetaBean meta = all.get(xmlMeta.getId());
            if (meta == null) {
              meta = createMetaBean(xmlMeta);
              all.put(xmlMeta.getId(), meta);
            }
            carrier.xmlMeta = xmlMeta;
View Full Code Here

      carrier.xmlInfos = xmlMetaBeanInfos;
      if (xmlMetaBeanInfos == null) continue;
      try {
        for (XMLMetaBean xmlMeta : xmlMetaBeanInfos.getBeans()) {
          nothing = false;
          MetaBean copy = copies.get(xmlMeta.getId());
          if (copy == null) { // ist noch nicht kopiert
            MetaBean meta = all.get(xmlMeta.getId());
            if (meta == null) { // gibt es nicht
              copy = createMetaBean(xmlMeta);
            } else { // gibt es, jetzt kopieren
              copy = meta.copy();
            }
            copies.put(xmlMeta.getId(), copy);
          }
          carrier.xmlMeta = xmlMeta;
          xmlFactory.enrichMetaBean(copy, carrier);
View Full Code Here

  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

  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

TOP

Related Classes of org.apache.bval.model.MetaBean

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.