private static void generateDeserializeIntoArray(JDefinedClass wrapperClass, String arrayItemJsonType,
                                                   Pair<JType, JClass> arrayItemType, boolean lenientDeserialize) {
    JCodeModel model = wrapperClass.owner();
    JClass jClass = arrayItemType.getValue();
    if (arrayItemType.getKey().equals(model.ref(List.class))) {
      wrapperClass._extends(model.ref(ArrayList.class).narrow(jClass));
    }
    else {
      wrapperClass._extends(model.ref(HashSet.class).narrow(jClass));
    }

    JBlock statements = attachDeserializerTo(wrapperClass);
    statements.decl(0, wrapperClass, "result", JExpr._new(wrapperClass));
    statements.decl(0, model.ref(JsonToken.class), "token", JExpr.invoke(JExpr.ref("parser"), "currentToken"));
    JConditional mainIf = statements._if(JExpr.ref("token").eq(model.ref(JsonToken.class).staticRef("START_ARRAY")));


    String[] jsonItemTypes = new String[]{arrayItemJsonType};
    if (jClass instanceof JDefinedClass) {
      Object metadata = ((JDefinedClass)jClass).metadata;
      if (metadata instanceof Map) {
        Object tokens = ((Map<?, ?>)metadata).get("tokens");
        if (tokens instanceof Set) {
          //noinspection unchecked
          jsonItemTypes = ((Set<String>)tokens).toArray(String[]::new);
        }
      }
    }

    JBlock whileBlock = mainIf._then()._while(JExpr.ref("parser").invoke("nextToken").ne(model.ref(JsonToken.class).staticRef("END_ARRAY")))
      .body();

    whileBlock.assign(JExpr.ref("token"), JExpr.invoke(JExpr.ref("parser"), "currentToken"));

    createAddToResultGuarded(whileBlock, jClass, jsonItemTypes, lenientDeserialize);

    createAddToResultGuarded(mainIf._else(), jClass, jsonItemTypes, lenientDeserialize);
    statements._return(JExpr.ref("result"));
  }
private static void generateDeserializeIntoArray(JDefinedClass wrapperClass, String arrayItemJsonType,
                                                   Pair<JType, JClass> arrayItemType, boolean lenientDeserialize)