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

public abstract class Node extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    @Nullable Object
     
    protected static final org.apache.logging.log4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Node(@Nullable String id, @Nullable Object title, @Nullable Object description)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addMetadata(String key, Object value)
     
    final void
     
    protected final void
     
    final <M> M
    Consume some metadata attached to this node meaning it will be removed
    abstract boolean
     
     
    final @UnmodifiableView @Nullable Map<String,Object>
     
    final <M> M
    Return some metadata attached to this node
    final <M> M
    Return some metadata attached to this node or put def if it is not present
    @Nullable Object
     
    final int
     
    final boolean
     
    void
    overwrite(Node with, boolean preserveMissingOptions)
     
    abstract void
    overwrite(Node with, boolean preserveMissingOptions, boolean skipOverwritten, @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 and any duplicate keys will be overwritten For a Property the value and callbacks and display conditions are copied onto this For a Tree all children and properties will be overwritten if they are present and this operation is recursive
    final boolean
     
    void
    setID(@NotNull String id)
    Set the ID of this node
    The ID is used solely by the backend to identify it and may only contain alphanumeric characters and underscores
    note that this operation is permanent and cannot be undone or changed
    void
     
    static Object
    validate and trim the given string returning null if it is empty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 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()
    • 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 and may only contain alphanumeric characters and underscores
      note that this operation is permanent and cannot be undone or 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 does not 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 if it is not 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 does not 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 does not 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 and any duplicate keys will be overwritten
      • For a Property the value and callbacks and display conditions are copied onto this
      • For a Tree all children and properties will be overwritten if they are present and this operation is recursive
      Parameters:
      with - the node to overwrite this with
      preserveMissingOptions - if true then any properties 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