docs: @SuppressWarnings("unchecked")
      public static <T> AttributeValue toAttributeValue(final T value, final Class collectionType) {
          if (value == null) {
              return null;
          } else if (String.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue((String) value);
          } else if (Number.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue().withN(value.toString());
          } else if (Boolean.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue().withBOOL((Boolean) value);
          } else if (Character.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue(value.toString());
          } else if (Byte.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue().withN(value.toString());
          } else if (byte[].class.isAssignableFrom(value.getClass())) {
              return new AttributeValue().withB(ByteBuffer.wrap((byte[]) value));
          } else if (Date.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue().withN(Long.toString(((Date) value).getTime()));
          } else if (Enum.class.isAssignableFrom(value.getClass())) {
              return new AttributeValue(((Enum) value).name());
          } else if (Set.class.isAssignableFrom(value.getClass())) {
              Set valueSet = (Set) value;
              Set<String> strings = new HashSet<String>(valueSet.size());
  
              for (Object next : valueSet) {
                  strings.add(toString(next));
              }
  
              if (collectionType != null && STORE_AS_NUMBER_CLASSES.contains(collectionType)) {
                  return new AttributeValue().withNS(strings);
              } else {
                  return new AttributeValue().withSS(strings);
              }
          } else if (List.class.isAssignableFrom(value.getClass())) {
              List valueList = (List) value;
              List<AttributeValue> attributeValues = new ArrayList<AttributeValue>(valueList.size());
  
              for (Object next : valueList) {
                  attributeValues.add(toAttributeValue(next));
              }
  
              return new AttributeValue().withL(attributeValues);
          } else if (Map.class.isAssignableFrom(value.getClass())) {
              Map<String, ?> valueMap = (Map<String, Object>) value;
              Map<String, AttributeValue> attributeValueMap = new HashMap<String, AttributeValue>(valueMap.size());
  
              for (Map.Entry<String, ?> entry : valueMap.entrySet()) {
                  attributeValueMap.put(entry.getKey(), toAttributeValue(entry.getValue()));
              }
  
              return new AttributeValue().withM(attributeValueMap);
          } else if (AttributeValue.class.isAssignableFrom(value.getClass())) {
              return (AttributeValue) value;
          } else {
              Enhancer<T> enhancer = EnhancerHelper.getPersistableEnhancer((Class<T>) value.getClass());
              DynamoDBPersistable dynamoDBPersistable = (DynamoDBPersistable) enhancer.enhance(value);
  
              return new AttributeValue().withM(getItemFromObject(dynamoDBPersistable));
          }
      }