Class Node

java.lang.Object
org.qubitpi.wilhelm.Node

@Immutable @ThreadSafe public class Node extends Object
A JSON-serializable object representation of a knowledge graph node in wilhelm-ws.

A Node has 3 public attributes:

  1. A unique string identifier within a knowledge graph
  2. A string used as the caption for rendering the node
  3. A map containing all other information encapsulated
  • Field Details

    • LABEL_ATTRIBUTE

      public static final String LABEL_ATTRIBUTE
      The database node attribute name whose value is used for displaying the node caption on UI.

      For example, for Neo4J database, this would correspond to a node property.

      See Also:
  • Method Details

    • valueOf

      public static Node valueOf(@NotNull org.neo4j.driver.types.Node node)
      Converts a Neo4J API node to a wilhelm-ws Node.

      The Neo4J node must contain a property called "name", otherwise an unchecked exception is thrown. The Entity.elementId() would be the ID of this node; the "name" property would be the label of this node.; the rest of the properties would be the attributes of this node

      Parameters:
      node - A Neo4J Java driver API node
      Returns:
      a new instance of converted Node
      Throws:
      NullPointerException - if node is null
      IllegalStateException - if node is missing a "name" property
    • getId

      @NotNull public @NotNull String getId()
    • getLabel

      @NotNull public @NotNull String getLabel()
    • getAttributes

      @NotNull public @NotNull Map<String,Object> getAttributes()
      Returns an immutable view of the attributes of this Node.
      Returns:
      an unmodifiable map
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this Node.

      The content of the string equals to the label of this Node.

      Overrides:
      toString in class Object
      Returns:
      a human-readable caption of this node