/** * Return the property level constraints for a given propertyName or {@code null} if * either the property does not exist or has no constraint. The returned * object (and associated objects including ConstraintDescriptors) are * immutable. * * @param propertyName * property evaluated */ public PropertyDescriptor getConstraintsForProperty(String propertyName) { if (propertyName == null || propertyName.trim().length() == 0) { throw new IllegalArgumentException("propertyName cannot be null or empty"); } MetaProperty prop = metaBean.getProperty(propertyName); if (prop == null) return null; // If no constraints and not cascaded, return null if (prop.getValidations().length == 0 && prop.getFeature(Features.Property.REF_CASCADE) == null) { return null; } return getPropertyDescriptor(prop); }
/** * {@inheritDoc} */ @Override public void buildMetaBean(MetaBean meta) throws Exception { if (meta.getBeanClass() == null) { return; // handle only, when local class exists } BeanInfo info = Introspector.getBeanInfo(meta.getBeanClass()); if (meta.getName() == null && info.getBeanDescriptor() != null) { meta.setName(info.getBeanDescriptor().getName()); // (display?)name = simple class name! } for (PropertyDescriptor pd : info.getPropertyDescriptors()) { if (!(pd instanceof IndexedPropertyDescriptor || pd.getName().equals("class"))) { MetaProperty metaProp = buildMetaProperty(pd, meta.getProperty(pd.getName())); meta.putProperty(pd.getName(), metaProp); } } }
protected MetaProperty enrichElement(MetaBean meta, XMLMetaElement xmlProp, XMLResult result) throws Exception { MetaProperty prop = meta.getProperty(xmlProp.getName()); if (prop == null) { prop = new MetaProperty(); prop.setName(xmlProp.getName()); meta.putProperty(xmlProp.getName(), prop); } xmlProp.mergeInto(prop); enrichValidations(prop, xmlProp, result, true); return prop; }
metaProperty = null; } else { // property level metaProperty = metabean.getProperty(access.getPropertyName()); create = metaProperty == null; if (create) { MetaProperty metaProperty = metabean.getProperty(access.getPropertyName()); boolean create = metaProperty == null; if (create) {
MetaProperty metaProperty = metabean.getProperty(field.getName()); if (!factoryContext.getFactory().getAnnotationIgnores().isIgnoreAnnotations(method)) { AccessStrategy access = new MethodAccess(propName, method); MetaProperty metaProperty = metabean.getProperty(propName); boolean create = metaProperty == null;
/** * {@inheritDoc} */ public void handleProperty(String token) { moveDownIfNecessary(); MetaBean metaBean = validationContext.getMetaBean(); if (metaBean instanceof DynamicMetaBean) { metaBean = metaBean.resolveMetaBean(ObjectUtils.defaultIfNull(validationContext.getBean(), rawType)); validationContext.setMetaBean(metaBean); } MetaProperty mp = metaBean.getProperty(token); if (mp == null) { // TODO this could indicate a property hosted on a superclass; should we shunt the context traversal down a path based on that type? PropertyAccess access = new PropertyAccess(rawType, token); if (access.isKnown()) { // add heretofore unknown, but valid, property on the fly: mp = Jsr303MetaBeanFactory.addMetaProperty(metaBean, access); } else { throw new UnknownPropertyException("unknown property '" + token + "' in " + metaBean.getId()); } } validationContext.setMetaProperty(mp); setType(mp.getType()); }