public static <T> T toEntity(final Class<T> targetClass, final JsonDocument jsonDocument) {
        final T result = toEntity(targetClass, jsonDocument.content());
        final String id = jsonDocument.id();

        if (N.notNullOrEmpty(id) && result != null) {
            if (Map.class.isAssignableFrom(targetClass)) {
                ((Map<String, Object>) result).put(_ID, id);
            } else {
                final Method idSetMethod = getObjectIdSetMethod(targetClass);

                if (idSetMethod != null) {
                    ClassUtil.setPropValue(result, idSetMethod, id);
                }
            }
        }

        return result;
    }
public static < T > T toEntity ( final Class < T > targetClass , final JsonDocument jsonDocument ) { final T result = toEntity ( targetClass , jsonDocument . content ( ) ) ; final String id = jsonDocument . id ( ) ; if ( N . notNullOrEmpty ( id ) && result != null ) { if ( Map . class . isAssignableFrom ( targetClass ) ) { ( ( Map < String , Object > ) result ) . put ( _ID , id ) ; } else { final Method idSetMethod = getObjectIdSetMethod ( targetClass ) ; if ( idSetMethod != null ) { ClassUtil . setPropValue ( result , idSetMethod , id ) ; } } } return result ; }
The id in the specified <code>jsonDocument</code> will be set to the returned object if and only if the id is not null or empty and the content in <code>jsonDocument</code> doesn't contain any "id" property, and it's acceptable to the <code>targetClass</code>.

@param targetClass an entity class with getter/setter method or <code>Map.class</code>
@param jsonDocument
@return