List of usage examples for org.springframework.beans NullValueInNestedPathException NullValueInNestedPathException
public NullValueInNestedPathException(Class<?> beanClass, String propertyName)
From source file:net.yasion.common.core.bean.wrapper.impl.ExtendedBeanWrapperImpl.java
/** * Retrieve a BeanWrapper for the given nested property. Create a new one if not found in the cache. * <p>//from ww w .j a v a 2 s. c om * Note: Caching nested BeanWrappers is necessary now, to keep registered custom editors for nested properties. * * @param nestedProperty * property to create the BeanWrapper for * @return the BeanWrapper instance, either cached or newly created */ private ExtendedBeanWrapperImpl getNestedBeanWrapper(String nestedProperty) { if (this.nestedBeanWrappers == null) { this.nestedBeanWrappers = new HashMap<String, ExtendedBeanWrapperImpl>(); } // Get value of bean property. PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); String canonicalName = tokens.canonicalName; Object value = getPropertyValue(tokens); if (value == null || (value.getClass().equals(javaUtilOptionalClass) && OptionalUnwrapper.isEmpty(value))) { if (isAutoGrowNestedPaths()) { value = setDefaultValue(tokens); } else { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); } } // Lookup cached sub-BeanWrapper, create new one if not found. ExtendedBeanWrapperImpl nestedBw = this.nestedBeanWrappers.get(canonicalName); if (nestedBw == null || nestedBw.getWrappedInstance() != (value.getClass().equals(javaUtilOptionalClass) ? OptionalUnwrapper.unwrap(value) : value)) { if (logger.isTraceEnabled()) { logger.trace("Creating new nested BeanWrapper for property '" + canonicalName + "'"); } nestedBw = newNestedBeanWrapper(value, this.nestedPath + canonicalName + NESTED_PROPERTY_SEPARATOR); // Inherit all type-specific PropertyEditors. copyDefaultEditorsTo(nestedBw); copyCustomEditorsTo(nestedBw, canonicalName); this.nestedBeanWrappers.put(canonicalName, nestedBw); } else { if (logger.isTraceEnabled()) { logger.trace("Using cached nested BeanWrapper for property '" + canonicalName + "'"); } } return nestedBw; }
From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java
/** * Retrieve a Property accessor for the given nested property. * Create a new one if not found in the cache. * <p>Note: Caching nested PropertyAccessors is necessary now, * to keep registered custom editors for nested properties. * @param nestedProperty property to create the PropertyAccessor for * @return the PropertyAccessor instance, either cached or newly created *///from w w w. j a v a2s. c o m private AbstractNestablePropertyAccessor getNestedPropertyAccessor(String nestedProperty) { if (this.nestedPropertyAccessors == null) { this.nestedPropertyAccessors = new HashMap<>(); } // Get value of bean property. PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); String canonicalName = tokens.canonicalName; Object value = getPropertyValue(tokens); if (value == null || (value instanceof Optional && !((Optional) value).isPresent())) { if (isAutoGrowNestedPaths()) { value = setDefaultValue(tokens); } else { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); } } // Lookup cached sub-PropertyAccessor, create new one if not found. AbstractNestablePropertyAccessor nestedPa = this.nestedPropertyAccessors.get(canonicalName); if (nestedPa == null || nestedPa.getWrappedInstance() != ObjectUtils.unwrapOptional(value)) { if (logger.isTraceEnabled()) { logger.trace("Creating new nested " + getClass().getSimpleName() + " for property '" + canonicalName + "'"); } nestedPa = newNestedPropertyAccessor(value, this.nestedPath + canonicalName + NESTED_PROPERTY_SEPARATOR); // Inherit all type-specific PropertyEditors. copyDefaultEditorsTo(nestedPa); copyCustomEditorsTo(nestedPa, canonicalName); this.nestedPropertyAccessors.put(canonicalName, nestedPa); } else { if (logger.isTraceEnabled()) { logger.trace("Using cached nested property accessor for property '" + canonicalName + "'"); } } return nestedPa; }
From source file:org.springframework.beans.BeanWrapperImpl.java
/** * Retrieve a BeanWrapper for the given nested property. * Create a new one if not found in the cache. * <p>Note: Caching nested BeanWrappers is necessary now, * to keep registered custom editors for nested properties. * @param nestedProperty property to create the BeanWrapper for * @return the BeanWrapper instance, either cached or newly created *///w w w . ja v a 2 s. co m private BeanWrapperImpl getNestedBeanWrapper(String nestedProperty) { if (this.nestedBeanWrappers == null) { this.nestedBeanWrappers = new HashMap<String, BeanWrapperImpl>(); } // Get value of bean property. PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); String canonicalName = tokens.canonicalName; Object value = getPropertyValue(tokens); if (value == null || (value.getClass().equals(javaUtilOptionalClass) && OptionalUnwrapper.isEmpty(value))) { if (isAutoGrowNestedPaths()) { value = setDefaultValue(tokens); } else { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); } } // Lookup cached sub-BeanWrapper, create new one if not found. BeanWrapperImpl nestedBw = this.nestedBeanWrappers.get(canonicalName); if (nestedBw == null || nestedBw.getWrappedInstance() != (value.getClass().equals(javaUtilOptionalClass) ? OptionalUnwrapper.unwrap(value) : value)) { if (logger.isTraceEnabled()) { logger.trace("Creating new nested BeanWrapper for property '" + canonicalName + "'"); } nestedBw = newNestedBeanWrapper(value, this.nestedPath + canonicalName + NESTED_PROPERTY_SEPARATOR); // Inherit all type-specific PropertyEditors. copyDefaultEditorsTo(nestedBw); copyCustomEditorsTo(nestedBw, canonicalName); this.nestedBeanWrappers.put(canonicalName, nestedBw); } else { if (logger.isTraceEnabled()) { logger.trace("Using cached nested BeanWrapper for property '" + canonicalName + "'"); } } return nestedBw; }
From source file:org.tinygroup.weblayer.webcontext.parser.util.BeanWrapperImpl.java
/** * Retrieve a BeanWrapper for the given nested property. * Create a new one if not found in the cache. * <p>Note: Caching nested BeanWrappers is necessary now, * to keep registered custom editors for nested properties. * @param nestedProperty property to create the BeanWrapper for * @return the BeanWrapper instance, either cached or newly created */// ww w. ja v a 2s .c o m private BeanWrapperImpl getNestedBeanWrapper(String nestedProperty) { if (this.nestedBeanWrappers == null) { this.nestedBeanWrappers = new HashMap<String, BeanWrapperImpl>(); } // Get value of bean property. PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); String canonicalName = tokens.canonicalName; Object propertyValue = getPropertyValue(tokens); if (propertyValue == null) { if (this.autoGrowNestedPaths) { propertyValue = setDefaultValue(tokens); } else { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); } } // Lookup cached sub-BeanWrapper, create new one if not found. BeanWrapperImpl nestedBw = this.nestedBeanWrappers.get(canonicalName); if (nestedBw == null || nestedBw.getWrappedInstance() != propertyValue) { if (logger.isTraceEnabled()) { logger.trace("Creating new nested BeanWrapper for property '" + canonicalName + "'"); } nestedBw = newNestedBeanWrapper(propertyValue, this.nestedPath + canonicalName + NESTED_PROPERTY_SEPARATOR); // Inherit all type-specific PropertyEditors. copyDefaultEditorsTo(nestedBw); copyCustomEditorsTo(nestedBw, canonicalName); this.nestedBeanWrappers.put(canonicalName, nestedBw); } else { if (logger.isTraceEnabled()) { logger.trace("Using cached nested BeanWrapper for property '" + canonicalName + "'"); } } return nestedBw; }