package com.readlearncode.object.lesson3;

import com.readlearncode.object.lesson1.ObjectExample2;

import javax.json.*;
import java.io.FileNotFoundException;

/**
 * Source code github.com/readlearncode
 *
 * @author Alex Theedom www.readlearncode.com
 * @version 1.0
 */
public class ObjectExample5 {

    public static void main(String... args) throws FileNotFoundException {
        JsonObject jsonObject = new ObjectExample2().loadJsonObject();
        new ObjectExample5().printValue(jsonObject);
    }

    private void printValue(JsonArray jsonValues) {
        jsonValues.forEach(jsonValue -> printValue("", jsonValue));
    }

    private void printValue(JsonObject jsonObject) {
        jsonObject.forEach(this::printValue);
    }

    private void printValue(String key, JsonValue jsonValue) {
        printKey(key);
        if (jsonValue instanceof JsonString) {
            printValue((JsonString) jsonValue);
            return;
        }
        if (jsonValue instanceof JsonArray) {
            printValue((JsonArray) jsonValue);
            return;
        }
        if (jsonValue instanceof JsonObject) {
            printValue((JsonObject) jsonValue);
            return;
        }
        if (jsonValue instanceof JsonNumber) {
            printValue((JsonNumber) jsonValue);
            return;
        }
        printValue(jsonValue.toString());
    }

    private void printKey(String key) {
        System.out.print(key);
    }

    private void printValue(JsonString jsonString) {
        printValue(jsonString.getString());
    }

    private void printValue(JsonNumber jsonNumber) {
        printValue(jsonNumber.toString());
    }

    private void printValue(String value) {
        System.out.println(" : " + value);
    }

}
@@ -495,32 +495,117 @@
 Object);%0A    %7D%0A%0A
+    /**%0A     * Processes Array types%0A     * @param jsonValues JsonArray type%0A     */%0A
     private void
@@ -707,32 +707,123 @@
 Value));%0A    %7D%0A%0A
+    /**%0A     * Processes JsonObject types%0A     * @param jsonObject JsonObject type%0A     */%0A
     private void
@@ -904,32 +904,197 @@
 tValue);%0A    %7D%0A%0A
+    /**%0A     * Delegates processing to appropriate printValue method based on type%0A     * @param key String key value%0A     * @param jsonValue JsonValue type%0A     */%0A
     private void
@@ -1702,32 +1702,106 @@
 ring());%0A    %7D%0A%0A
+    /**%0A     * Prints the key name%0A     * @param key the key name%0A     */%0A
     private void
@@ -1854,32 +1854,129 @@
 nt(key);%0A    %7D%0A%0A
+    /**%0A     * Prints the JsonString value%0A     * @param jsonString the JsonString value%0A     */%0A
     private void
@@ -2055,32 +2055,129 @@
 ring());%0A    %7D%0A%0A
+    /**%0A     * Prints the JsonNumber value%0A     * @param jsonNumber the JsonNumber value%0A     */%0A
     private void
@@ -2259,24 +2259,125 @@
 ());%0A    %7D%0A%0A
+    /**%0A     * Prints the String vlaue to the console%0A     * @param value the value to print%0A     */%0A
     private 

Add comments ObjectExample5