All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.endreman0.javajson.nodes.Node Maven / Gradle / Ivy

There is a newer version: 0.13.0
Show newest version
package io.github.endreman0.javajson.nodes;

/**
 * All JSON nodes have a few properties in common.
 * 
    *
  • They all have a parent node, and
  • *
  • Given another node with the same values and/or children, the two nodes will be considered equal.
  • *
* @author endreman0 */ public abstract class Node{ protected ParentNode parent; protected Node(){} /** * Remove this node from its parent. */ public void remove(){if(parent != null) parent.remove(this);} /** * Get the parent of this node. * @return the node's parent */ public ParentNode parent(){return parent;} /** * Get a textual representation of the JSON for this node. * @return the JSON text for this node */ public abstract String json(); /** * Get a textual representation of the contents of this node. * For objects and arrays, this will be just their children without being wrapped in curly brackets and square brackets. * For strings, this will be the contained string. * For booleans, numbers, and null, this will be the same as {@link #json()}. * @return The JSON text for the contents of this node */ public abstract String innerJSON(); @Override public String toString(){return json();} @Override public abstract boolean equals(Object obj); @Override public abstract int hashCode(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy