Exemplo n.º 1
0
  @Override
  public void execute() throws MojoExecutionException {
    try {
      JavaProjectBuilder builder = new JavaProjectBuilder();
      builder.addSourceTree(new File(srcDirectory, "src/main/java"));

      ObjectNode root = initializeRoot();
      ArrayNode tags = mapper.createArrayNode();
      ObjectNode paths = mapper.createObjectNode();

      root.set("tags", tags);
      root.set("paths", paths);

      builder.getClasses().forEach(jc -> processClass(jc, paths, tags));

      if (paths.size() > 0) {
        getLog().info("Generating ONOS REST API documentation...");
        genCatalog(root);

        if (!isNullOrEmpty(apiPackage)) {
          genRegistrator();
        }
      }

      project.addCompileSourceRoot(new File(dstDirectory, GEN_SRC).getPath());

    } catch (Exception e) {
      getLog().warn("Unable to generate ONOS REST API documentation", e);
      throw e;
    }
  }
Exemplo n.º 2
0
  private static void testJson() {
    String json1 = "[\"hello\"]";
    JsonNode jsonNode = Json.parse(json1);
    Json.stringify(jsonNode);
    System.out.println(jsonNode.toString());
    System.out.println(Json.stringify(jsonNode));
    ObjectNode jsonObject = Json.newObject();
    jsonObject.put("hello", jsonNode);
    jsonObject.put("hello", 56);
    System.out.println(jsonObject.toString());
    List<Object> strings = new ArrayList<Object>();
    strings.add("hello");
    strings.add("world");
    jsonObject.put("test", Json.toJson(strings));
    System.out.println(jsonObject.toString());
    jsonObject.put("test2", Json.toJson("string"));
    jsonObject.put("test2", Json.toJson("sshshhs"));
    List<String> list = new ArrayList<String>();
    list.add("hello me");
    // ObjectNode objectNode = Json.newObject();

    jsonObject.put("me", Json.toJson(list));
    System.out.println(jsonObject.toString());
    System.out.println(jsonObject.size());
    System.out.println(jsonObject.get("test").isArray());
    JsonNode jsonNode1 = jsonObject.get("test");
    Iterator iterator = jsonNode1.iterator();
    while ((iterator.hasNext())) {
      System.out.println(iterator.next());
    }
    Iterator<JsonNode> iterator1 = jsonObject.iterator();
    while (iterator1.hasNext()) {
      System.out.println("----------------------");
      JsonNode jsonNode2 = iterator1.next();
      if (jsonNode2.isArray()) {
        Iterator iterator2 = jsonNode2.iterator();
        while ((iterator2.hasNext())) {
          System.out.println(iterator2.next());
        }
      } else {
        if (jsonNode2.isTextual()) {
          System.out.println("String:" + jsonNode2);
        }
      }
    }
  }