code: public static Object convert(Object source, Attribute attr) {
      try {
        return convert(source, attr.getDataType());
      } catch (DataConversionException e) {
        throw new AttributeValueConversionException(
            format(
                "Conversion failure in entity type [%s] attribute [%s]; %s",
                attr.getEntity().getId(), attr.getName(), e.getMessage()),
            e);
      }
    }
docs: Convert value to the type based on the given attribute.
  
  @param source value to convert
  @param attr attribute that defines the type of the converted value
  @return converted value or the input value if the attribute type is a reference type
  @throws AttributeValueConversionException if conversion failed