Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4584

Validate map types

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Unknown Unknown
    • None
    • None
    • POJO
    • None

    Description

      Validate Map types to ensure when writing to the Pojo or to MongoDB they are of type Map<String, ?>. Check any concrete Map implementations eg:

       Type[] genericInterfaces = Document.class.getGenericInterfaces();
              for (var type : genericInterfaces) {
                  if (type instanceof ParameterizedType parameterizedType) {
                      System.out.println(parameterizedType.getRawType().getTypeName());
                      for (var typeArguments : parameterizedType.getActualTypeArguments()) {
                          System.out.println("   " + typeArguments.getTypeName());
                      }
                  }
              }
      prints:
       
      java.util.Map
         java.lang.String
         java.lang.Object
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: