Module watamebot

Class KVPFile

java.lang.Object
net.foxgenesis.config.KVPFile

public class KVPFile extends Object
Key Value Pair (KVP) file implementation.
Author:
Ashley
  • Constructor Details

  • Method Details

    • forEach

      public void forEach(BiConsumer<? super String,? super String> action)
      Performs the given action for each entry in this map until all entrieshave been processed or the action throws an exception. Unlessotherwise specified by the implementing class, actions are performed inthe order of entry set iteration (if an iteration order is specified.)Exceptions thrown by the action are relayed to the caller.
      Parameters:
      action - - The action to be performed for each entry
      See Also:
    • get

      @Nullable public String get(String key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

      More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

      If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the value to which the specified key is mapped, or null if this map contains no mapping for the key
      Throws:
      ClassCastException - if the key is of an inappropriate type for this map (optional)
      NullPointerException - if the specified key is null and this map does not permit null keys (optional)
      See Also:
    • getOrDefault

      @Nullable public String getOrDefault(String key, String defaultValue)
      Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
      Parameters:
      key - the key whose associated value is to be returned
      defaultValue - the default mapping of the key
      Returns:
      the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key
      Throws:
      ClassCastException - if the key is of an inappropriate type for this map (optional)
      NullPointerException - if the specified key is null and this map does not permit null keys (optional)
      See Also:
    • containsKey

      public boolean containsKey(String key)
      Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)
      Parameters:
      key - key whose presence in this map is to be tested
      Returns:
      true if this map contains a mapping for the specified key
      Throws:
      ClassCastException - if the key is of an inappropriate type for this map (optional)
      NullPointerException - if the specified key is null and this map does not permit null keys (optional)
    • clear

      public void clear()
      Clear the configuration mapping.
    • isEmpty

      public boolean isEmpty()
      Checks if the configuration mapping is empty.
      Returns:
      Returns true if there are no configuration entries mapped
    • parse

      public void parse(@Nonnull URL resourceURL) throws IOException
      Parse a resource URL into the configuration mapping.
      Parameters:
      resourceURL - - URL pointing to the resource to parse
      Throws:
      IOException - Thrown if an error occurs while reading the InputStream of the resource
    • parse

      public void parse(@Nonnull InputStream input) throws IOException
      Parse an InputStream into the configuration mapping.
      Parameters:
      input - - the input stream to parse
      Throws:
      IOException - Thrown if an error occurs while reading the InputStream of the resource
    • parse

      public void parse(@Nonnull ResourceUtils.ModuleResource resource) throws IOException
      Parse a ResourceUtils.ModuleResource into the configuration mapping.
      Parameters:
      resource - - the resource to parse
      Throws:
      IOException - Thrown if an error occurs while reading the InputStream of the resource