/*
 * Copyright 2016 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.terasology.rendering.nui.widgets.models;

import com.google.gson.JsonElement;

/**
 * The value type for the tree representation of a {@link JsonElement}.
 */
public class JsonTreeNode {
    /**
     * The type of the JSON node.
     */
    public enum ElementType {
        // Primitive data type (string, boolean, array).
        VALUE,
        // A primitive data type paired with a key string.
        KEY_VALUE_PAIR,
        // An ordered list of zero or more values.
        ARRAY,
        // An unordered list of name/value pairs.
        OBJECT,
        // An empty value.
        NULL
    }

    /**
     * The default name for a JSON object node.
     */
    private static final String OBJECT_STRING = "{}";
    /**
     * The default name for a JSON array node.
     */
    private static final String ARRAY_STRING = "[]";
    /**
     * The default name for a null JSON node.
     */
    private static final String NULL_STRING = "null";
    /**
     * The name of the node.
     */
    private String key;
    /**
     * The value stored within the node.
     */
    private Object value;
    /**
     * The type of the node.
     */
    private ElementType type;

    public JsonTreeNode(String key, Object value, ElementType type) {
        this.key = key;
        this.value = value;
        this.type = type;
    }

    public String getKey() {
        return this.key;
    }

    public Object getValue() {
        return this.value;
    }

    public ElementType getType() {
        return this.type;
    }

    @Override
    public String toString() {
        if (type == ElementType.KEY_VALUE_PAIR) {
            if (key != null && value != null) {
                return key + ": " + value;
            }
            return key == null ? value.toString() : key;
        } else if (type == ElementType.VALUE) {
            return value.toString();
        } else if (type == ElementType.ARRAY) {
            return key != null ? key : ARRAY_STRING;
        } else if (type == ElementType.OBJECT) {
            return key != null ? key : OBJECT_STRING;
        } else {
            return key != null ? key : NULL_STRING;
        }
    }
}

@@ -878,17 +878,29 @@
        /
-/
+**%0A         *
  Primiti
@@ -938,16 +938,28 @@
 array).%0A
+         */%0A
         
@@ -974,17 +974,29 @@
        /
-/
+**%0A         *
  A primi
@@ -1036,16 +1036,28 @@
 string.%0A
+         */%0A
         
@@ -1077,25 +1077,37 @@
 R,%0A        /
-/
+**%0A         *
  An ordered 
@@ -1135,16 +1135,28 @@
 values.%0A
+         */%0A
         
@@ -1167,25 +1167,37 @@
 Y,%0A        /
-/
+**%0A         *
  An unordere
@@ -1224,16 +1224,28 @@
  pairs.%0A
+         */%0A
         
@@ -1261,17 +1261,29 @@
        /
-/
+**%0A         *
  An empt
@@ -1291,16 +1291,28 @@
  value.%0A
+         */%0A
         

Make some inline comments multilne