PropertyDescriptor subDescriptor = BeanUtil .getPropertyDescriptor(instanceKey.type, name); moreProps.put(name, new NestedBeanPropertyDefinition<>(this, parentProperty, subDescriptor));
@Override public Optional<Setter<T, V>> getSetter() { if (getDescriptor().getWriteMethod() == null) { return Optional.empty(); } Setter<T, V> setter = (bean, value) -> { // Do not "optimize" this getter call, // if its done outside the code block, that will produce // NotSerializableException because of some lambda compilation // magic Method innerSetter = getDescriptor().getWriteMethod(); invokeWrapExceptions(innerSetter, parent.getGetter().apply(bean), value); }; return Optional.of(setter); }
@Override public ValueProvider<T, V> getGetter() { return bean -> { Method readMethod = getDescriptor().getReadMethod(); Object value = invokeWrapExceptions(readMethod, parent.getGetter().apply(bean)); return getType().cast(value); }; }
BeanUtil.getPropertyDescriptor(instanceKey.type, name)); if (descriptor.isPresent()) { NestedBeanPropertyDefinition<T, ?> nestedDefinition = new NestedBeanPropertyDefinition<>( this, parent.get(), descriptor.get()); definitions.put(name, nestedDefinition);
/** * Finds the bean type containing the property the given definition refers * to. * * @param beanType * the root beanType * @param definition * the definition for the property * @return the bean type containing the given property */ @SuppressWarnings({ "rawtypes" }) private Class<?> findBeanType(Class<BEAN> beanType, PropertyDefinition<BEAN, ?> definition) { if (definition instanceof NestedBeanPropertyDefinition) { return ((NestedBeanPropertyDefinition) definition).getParent() .getType(); } else { // Non nested properties must be defined in the main type return beanType; } }
private Object writeReplace() { /* * Instead of serializing this actual property definition, only * serialize a DTO that when deserialized will get the corresponding * property definition from the cache. */ return new SerializedPropertyDefinition( getPropertySet().instanceKey.type, getName()); }