code: private void copyAttributes(ElementBase src, LayoutElement dest) {
          for (PropertyInfo propInfo : src.getDefinition().getProperties()) {
              Object value = propInfo.isSerializable() ? propInfo.getPropertyValue(src) : null;
              String val = value == null ? null : propInfo.getPropertyType().getSerializer().serialize(value);
              
              if (!ObjectUtils.equals(value, propInfo.getDefault())) {
                  dest.getAttributes().put(propInfo.getId(), val);
              }
          }
      }
docs: Copy attributes from a UI element to layout element.
  
  @param src UI element.
  @param dest Layout element.