java.lang.Object
org.polyfrost.oneconfig.api.config.v1.Node
Direct Known Subclasses:
Property, Tree

public abstract class Node extends Object
  • Field Details

    • LOGGER

      protected static final org.apache.logging.log4j.Logger LOGGER
    • description

      @Nullable public transient @Nullable Object description
  • Constructor Details

    • Node

      public Node(@Nullable @Nullable String id, @Nullable @Nullable Object title, @Nullable @Nullable Object description)
  • Method Details

    • strv

      @Contract("null -> null") public static Object strv(Object s)
      validate and trim the given string, returning null if it is empty.
    • getID

      public String getID()
      The ID of this node.
    • setID

      public void setID(@NotNull @NotNull String id)
      Set the ID of this node. the ID is used solely by the backend to identify it. It may only contain alphanumeric characters, and underscores.
      note that this operation is permanent and cannot be undone/changed!
    • getTitle

      @Nullable public @Nullable Object getTitle()
    • setTitle

      public void setTitle(Object title)
    • addMetadata

      public final void addMetadata(String key, Object value)
    • addMetadata

      public final void addMetadata(Map<String,Object> metadata)
    • removeMetadata

      public final boolean removeMetadata(String key)
    • getMetadata

      @Nullable public final <M> M getMetadata(String key)
      Return some metadata attached to this node.
      Type Parameters:
      M - the type of the metadata
      Parameters:
      key - the key of the metadata
      Returns:
      the metadata, or null if it doesn't exist
      Throws:
      ClassCastException - if the metadata is not of the expected type M
    • getOrPutMetadata

      @NotNull public final <M> M getOrPutMetadata(String key, Supplier<M> def)
      Return some metadata attached to this node, or put def it is isn't present.
      Type Parameters:
      M - the type of the metadata
      Parameters:
      key - the key of the metadata
      def - the default value to put if there currently is no metadata on this value
      Returns:
      the metadata, or null if it doesn't exist
    • consumeMetadata

      @Nullable public final <M> M consumeMetadata(String key)
      Consume some metadata attached to this node, meaning it will be removed.
      Type Parameters:
      M - the type of the metadata
      Parameters:
      key - the key of the metadata
      Returns:
      the metadata, or null if it doesn't exist
    • getMetadata

      @Nullable public final @UnmodifiableView @Nullable Map<String,Object> getMetadata()
    • clearMetadata

      protected final void clearMetadata()
    • hasMetadata

      public final boolean hasMetadata()
    • overwrite

      public void overwrite(Node with, boolean preserveMissingOptions)
    • overwrite

      public abstract void overwrite(Node with, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable @Nullable Tree root)
      Overwrite all data in this node with the data from another node.
      • For a node, all metadata will be copied from the input onto this. any duplicate keys will be overwritten.
      • For a Property, the value, callbacks and display conditions are copied onto this.
      • For a Tree, all children and properties will be overwritten if they are present. this operation is recursive.
      Parameters:
      with - the node to overwrite this with
      preserveMissingOptions - if true, any properties that are missing in THIS tree that are present in the input tree, will be added to this tree.
      skipOverwritten - **DEPENDS ON PARAM "ROOT" BEING NOT NULL** - skips being overwritten if a child node has already been marked as overwritten in the root tree.
      root - The root tree used to mark overwritten nodes for skipOverwritten. May be null if skipOverwritten is false.
    • deepEquals

      @VisibleForTesting @Contract(pure=true) public abstract boolean deepEquals(Object other)
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object