Enum Class EntryPresence

java.lang.Object
java.lang.Enum<EntryPresence>
com.ultikits.ultitools.config.EntryPresence
All Implemented Interfaces:
Serializable, Comparable<EntryPresence>, java.lang.constant.Constable

public enum EntryPresence extends Enum<EntryPresence>
The condition an operator's map-entry write is made under: whether the entry must already be in the configuration file, or must not be, when the write happens.

Used with AbstractConfigEntity#saveOperatorMapEntry(EntryPresence, String, String...). An operator command that creates an entry (/autoreply add <name>) writes under MUST_BE_ABSENT, so it never replaces an entry of that name the operator added to the file by hand since it was read. A command that changes an existing entry (/autoreply setkeyword <name>) writes under MUST_BE_PRESENT, so it never writes back an entry the operator deleted by hand.

The condition is decided on the same read of the file that the configuration write gate verifies the write against. An edit saved after that read is never written over: the gate then refuses the write because the file changed.

What "present" means. The entry is present when its whole key path exists in the file. The path is where the framework reads the setting (its nested keys, or the flat dotted key the operator wrote), followed by the map keys, each of them one whole key. An entry holding null (name: ~) is present. An entry is absent when its key is missing, or when a key above it is missing, null, an empty map ({}) or not a map. A file that is missing, empty or holds only comments holds no entry.

Since:
6.3.0
  • Enum Constant Details

    • MUST_BE_PRESENT

      public static final EntryPresence MUST_BE_PRESENT
      The entry must already be in the file; the write changes or removes it and never creates it.
    • MUST_BE_ABSENT

      public static final EntryPresence MUST_BE_ABSENT
      The entry must not be in the file yet; the write creates it and never replaces one the file holds.
  • Constructor Details

    • EntryPresence

      private EntryPresence()
  • Method Details

    • values

      public static EntryPresence[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EntryPresence valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null