/** * {@inheritDoc} */ @Override protected void complete() { super.complete(); if (validationContext.getMetaProperty() != null) { return; } if (validationContext.getMetaBean() instanceof DynamicMetaBean) { validationContext.setMetaBean(validationContext.getMetaBean().resolveMetaBean( ObjectUtils.defaultIfNull(validationContext.getBean(), rawType))); } } }
/** * {@inheritDoc} */ public void handleIndexOrKey(String token) { moveDownIfNecessary(); AccessStrategy access; if (IndexedAccess.getJavaElementType(type) != null) { try { Integer index = token == null ? null : Integer.valueOf(token); access = new IndexedAccess(type, index); validationContext.setCurrentIndex(index); } catch (NumberFormatException e) { throw new UnknownPropertyException(String.format("Cannot parse %s as an array/iterable index", token), e); } } else if (KeyedAccess.getJavaElementType(type) != null) { access = new KeyedAccess(type, token); validationContext.setCurrentKey(token); } else { throw new UnknownPropertyException(String.format("Cannot determine index/key type for %s", type)); } Object value = validationContext.getBean(); Object child = value == null ? null : access.get(value); setType(child == null ? access.getJavaType() : child.getClass()); validationContext.setBean(child, validationContext.getMetaBean().resolveMetaBean(child == null ? rawType : child)); }
/** * {@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()); }
contextTraversal.moveDownIfNecessary(); if (context.getMetaBean() instanceof DynamicMetaBean) { context.setMetaBean(context.getMetaBean().resolveMetaBean( ObjectUtils.defaultIfNull(context.getBean(), contextTraversal.getRawType()))); contextTraversal.moveDownIfNecessary(); if (context.getMetaBean() instanceof DynamicMetaBean) { context.setMetaBean(context.getMetaBean().resolveMetaBean( ObjectUtils.defaultIfNull(context.getBean(), contextTraversal.getRawType())));