Class KarmaFile

java.lang.Object
ml.karmaconfigs.api.common.karmafile.KarmaFile
All Implemented Interfaces:
Serializable

public final class KarmaFile extends Object implements Serializable
Karma file
See Also:
Serialized Form
  • Constructor Details

    • KarmaFile

      public KarmaFile(KarmaSource source, String name, String... dir) throws IllegalStateException
      Initialize the karma file
      Parameters:
      source - the file source
      name - the file name
      dir - the file path
      Throws:
      IllegalStateException - if the target path is not a valid path
    • KarmaFile

      public KarmaFile(File target)
      Initialize the karma file
      Parameters:
      target - the target karma file
    • KarmaFile

      public KarmaFile(Path target)
      Initialize the karma file
      Parameters:
      target - the target karma file
  • Method Details

    • exportFromFile

      public void exportFromFile(InputStream resource)
      Export the karma file from an internal file
      Parameters:
      resource - the internal file
    • applyKarmaAttribute

      public void applyKarmaAttribute()
      Apply karma file attribute to the file
    • create

      public void create()
      Create the file
    • set

      public void set(Object value)
      Set a new value
      Parameters:
      value - the value
    • set

      public void set(String path, Object value)
      Set a new value
      Parameters:
      path - the key path
      value - the value
    • set

      public void set(String path, List<?> list)
      Set a new value
      Parameters:
      path - the key path
      list - the values
    • unset

      public void unset(String path)
      Unset a key and its value if set
      Parameters:
      path - the key path
    • unsetList

      public void unsetList(String path)
      Unset a list
      Parameters:
      path - the list path
    • delete

      public void delete()
      Delete the file
    • get

      @NotNull public @NotNull Object get(String path, @NotNull @NotNull Object def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getString

      @NotNull public @NotNull String getString(String path, @NotNull @NotNull String def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getList

      @NotNull public @NotNull List<?> getList(String path, Object... default_contents)
      Get a value
      Parameters:
      path - the value path
      default_contents - the default values
      Returns:
      the value
    • getStringList

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

      @NotNull public @NotNull List<String> readFullFile()
      Read the file completely
      Returns:
      the file lines
    • getBoolean

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

      public boolean isList(String path)
      Get if a key is a list
      Parameters:
      path - the key
      Returns:
      if the path is a list
    • isSet

      public boolean isSet(String path)
      Get if a key is set
      Parameters:
      path - the key
      Returns:
      if the path is set
    • getInt

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

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

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

      public float getFloat(String path, float def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getShort

      public short getShort(String path, short def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getByte

      public byte getByte(String path, byte def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getBytes

      public byte[] getBytes(String path, byte[] def)
      Get a value
      Parameters:
      path - the value path
      def - the default value
      Returns:
      the value
    • getFile

      public File getFile()
      Get the file
      Returns:
      the file
    • exists

      public boolean exists()
      Get if the file exists
      Returns:
      if the file exists
    • getKeys

      public Set<Key> getKeys(boolean deep)
      Get the karma file key set
      Parameters:
      deep - include non-valued keys
      Returns:
      the karma file keys
    • toString

      public String toString()
      Get the karma file as string
      Overrides:
      toString in class Object
      Returns:
      the karma file as string