Class KarmaYamlManager

java.lang.Object
ml.karmaconfigs.api.common.karmafile.karmayaml.KarmaYamlManager

public final class KarmaYamlManager extends Object
Karma yaml manager
  • Constructor Details

    • KarmaYamlManager

      public KarmaYamlManager(KarmaSource source, String name, String... sub)
      Initialize the karma yaml manager
      Parameters:
      source - the yaml source
      name - the yaml file name
      sub - the yaml file folder
    • KarmaYamlManager

      public KarmaYamlManager(Reader configuration)
      Initialize the karma yaml manager
      Parameters:
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(InputStream configuration)
      Initialize the karma yaml manager
      Parameters:
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(String configuration, boolean isPath)
      Initialize the karma yaml manager
      Parameters:
      configuration - the yaml configuration/path
      isPath - if the yaml configuration string is a path
    • KarmaYamlManager

      public KarmaYamlManager(File configuration)
      Initialize the karma yaml manager
      Parameters:
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(Path configuration)
      Initialize the karma yaml manager
      Parameters:
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(Map<?,​?> values)
      Initialize the karma yaml manager
      Parameters:
      values - the yaml key/value
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, KarmaSource source, String name, String... sub)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      source - the yaml source
      name - the yaml file name
      sub - the yaml file folder
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, Reader configuration)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, InputStream configuration)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, String configuration, boolean isPath)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      configuration - the yaml configuration/path
      isPath - if the yaml configuration string is a path
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, File configuration)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, Path configuration)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      configuration - the yaml
    • KarmaYamlManager

      public KarmaYamlManager(@NotNull @NotNull KarmaYamlManager defaults, Map<?,​?> values)
      Initialize the karma yaml manager
      Parameters:
      defaults - the yaml defaults
      values - the yaml key/value
  • Method Details

    • spacer

      public KarmaYamlManager spacer(char spacerChar)
      Set the manager spacer
      Parameters:
      spacerChar - the manager spacer
      Returns:
      this instance
    • update

      public void update(KarmaYamlManager configuration, boolean addNew, String... ignore)
      Update the current manager
      Parameters:
      configuration - the configuration to update from
      addNew - add non-existent keys
      ignore - ignored keys
    • set

      @NotNull public @NotNull KarmaYamlManager set(String path, Object value)
      Set the yaml value
      Parameters:
      path - the key path
      value - the key value
      Returns:
      this instance
    • store

      @NotNull public <T> @NotNull KarmaYamlManager store(String path, T object)
      Store an object instance
      Type Parameters:
      T - the type to store
      Parameters:
      path - the instance object path
      object - the object to store
      Returns:
      this instance
    • getSourceRoot

      @NotNull public @NotNull KYMSource getSourceRoot()
      Get the yaml source root
      Returns:
      the yaml source root
    • getReloader

      @Nullable public @Nullable YamlReloader getReloader()
      Get the yaml reloader
      Returns:
      the yaml reloader ( only valid for file/path/configuration path yaml generated sources )
    • getRoot

      @NotNull public @NotNull String getRoot()
      Get the yaml root key
      Returns:
      the yaml root key
    • getParent

      @Nullable public @Nullable KarmaYamlManager getParent()
      Get the yaml parent
      Returns:
      the yaml parent
    • getParents

      @NotNull public @NotNull KarmaYamlManager[] getParents()
      Get the yaml parents
      Returns:
      all the yaml parents
    • getChildren

      @NotNull public @NotNull KarmaYamlManager[] getChildren()
      Get the yaml children
      Returns:
      all the yaml children
    • getTreeMaster

      @NotNull public @NotNull KarmaYamlManager getTreeMaster()
      Get the master tree of the yaml parent
      Returns:
      the master tree of the yaml parent
    • save

      @NotNull public @NotNull KarmaYamlManager save(File target)
      Save the current yaml
      Parameters:
      target - the file to save in
      Returns:
      this instance
    • save

      @NotNull public @NotNull KarmaYamlManager save(File target, KarmaSource source, String resource)
      Save the current yaml
      Parameters:
      target - the file to save in
      source - the source to read defaults from
      resource - the internal resource to read defaults from
      Returns:
      this instance
    • getKeySet

      @NotNull public @NotNull Set<String> getKeySet()
      Get the yaml keys
      Returns:
      the yaml key set
    • get

      public Object get(String path, Object def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • get

      @Nullable public @Nullable Object get(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getList

      @NotNull public @NotNull List<Object> getList(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getList

      @NotNull public @NotNull List<Object> getList(String path, Object... defaults)
      Get a value
      Parameters:
      path - the key path
      defaults - the key default values
      Returns:
      the yaml value
    • getString

      @NotNull public @NotNull String getString(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getString

      public String getString(String path, String def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • getInt

      public int getInt(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getInt

      public int getInt(String path, int def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • getDouble

      public double getDouble(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getDouble

      public double getDouble(String path, double def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • getLong

      public long getLong(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getLong

      public long getLong(String path, long def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • getBoolean

      public boolean getBoolean(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getBoolean

      public boolean getBoolean(String path, boolean def)
      Get a value
      Parameters:
      path - the key path
      def - the key default value
      Returns:
      the yaml value
    • getStringList

      @NotNull public @NotNull List<String> getStringList(String path)
      Get a value
      Parameters:
      path - the key path
      Returns:
      the yaml value
    • getStringList

      @NotNull public @NotNull List<String> getStringList(String path, String... defaults)
      Get a value
      Parameters:
      path - the key path
      defaults - the key default values
      Returns:
      the yaml value
    • getInstance

      @Nullable public <T> T getInstance(String path)
      Get an object instance
      Type Parameters:
      T - the instance type
      Parameters:
      path - the instance string key
      Returns:
      the instance object
    • getSection

      @NotNull public @NotNull KarmaYamlManager getSection(String path)
      Get a section of the yaml
      Parameters:
      path - the section path
      Returns:
      the section
    • getSection

      @NotNull public @NotNull KarmaYamlManager getSection(String path, KarmaYamlManager defaults)
      Get a section of the yaml
      Parameters:
      path - the section path
      defaults - the section defaults
      Returns:
      the section
    • isSection

      public boolean isSection(String path)
      Get if the specified key is a section
      Parameters:
      path - the key
      Returns:
      if the path is a section
    • isSet

      public boolean isSet(String path)
      Get if the specified key is set in the yaml file
      Parameters:
      path - the key
      Returns:
      if the path is set
    • matchesWith

      public boolean matchesWith(String path, Class<?> expected)
      Get if the specified value matches with the expected value
      Parameters:
      path - the key
      expected - the expected value type
      Returns:
      if the value matches with the expected value type
    • toString

      @NotNull public @NotNull String toString()
      Yaml to string
      Overrides:
      toString in class Object
      Returns:
      the yaml as string