Record Class PropertyConfig

java.lang.Object
java.lang.Record
net.luis.utils.io.data.property.PropertyConfig
Record Components:
separator - The separator between key and value
alignment - The number of spaces between key and value (write-only)
commentCharacters - The characters that indicate a comment line (read-only)
keyPattern - The pattern that a key must match
valuePattern - The pattern that a value must match
advancedParsing - Whether to use advanced parsing (read-only)
charset - The charset to use for reading and writing

public record PropertyConfig(char separator, @WriteOnly int alignment, @ReadOnly @NotNull Set<Character> commentCharacters, @NotNull Pattern keyPattern, @NotNull Pattern valuePattern, @ReadOnly boolean advancedParsing, @NotNull Charset charset) extends Record
Configuration for reading and writing properties.
  • Field Details

    • separator

      private final char separator
      The field for the separator record component.
    • alignment

      private final int alignment
      The field for the alignment record component.
    • commentCharacters

      @NotNull private final @NotNull Set<Character> commentCharacters
      The field for the commentCharacters record component.
    • keyPattern

      @NotNull private final @NotNull Pattern keyPattern
      The field for the keyPattern record component.
    • valuePattern

      @NotNull private final @NotNull Pattern valuePattern
      The field for the valuePattern record component.
    • advancedParsing

      private final boolean advancedParsing
      The field for the advancedParsing record component.
    • charset

      @NotNull private final @NotNull Charset charset
      The field for the charset record component.
    • DEFAULT

      public static final PropertyConfig DEFAULT
      The default property configuration.
      Separator: '='
      Alignment: 1
      Comment characters: '#'
      Key pattern: "^[a-zA-Z0-9._-]+$"
      Value pattern: ".*"
      Advanced parsing: false
      Charset: UTF-8
  • Constructor Details

    • PropertyConfig

      public PropertyConfig(char separator, int alignment, @NotNull @NotNull Set<Character> commentCharacters, @NotNull @NotNull Pattern keyPattern, @NotNull @NotNull Pattern valuePattern, boolean advancedParsing, @NotNull @NotNull Charset charset)
      Constructs a new property configuration.
      Parameters:
      separator - The separator between key and value
      alignment - The number of spaces between key and value
      commentCharacters - The characters that indicate a comment line
      keyPattern - The pattern that a key must match
      valuePattern - The pattern that a value must match
      advancedParsing - Whether to use advanced parsing
      charset - The charset to use for reading and writing
      Throws:
      NullPointerException - If any of the parameters is null
      IllegalArgumentException - If the separator is a whitespace character or a comment character
  • Method Details

    • ensureKeyMatches

      public void ensureKeyMatches(@NotNull @NotNull String key)
      Checks whether the given key matches the key pattern.
      Parameters:
      key - The key to check
      Throws:
      NullPointerException - If the key is null
      PropertySyntaxException - If the key is blank or does not match the key pattern
    • ensureValueMatches

      public void ensureValueMatches(@NotNull @NotNull String value)
      Checks whether the given value matches the value pattern.
      Parameters:
      value - The value to check
      Throws:
      NullPointerException - If the value is null
      PropertySyntaxException - If the value does not match the value pattern
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • separator

      public char separator()
      Returns the value of the separator record component.
      Returns:
      the value of the separator record component
    • alignment

      public int alignment()
      Returns the value of the alignment record component.
      Returns:
      the value of the alignment record component
    • commentCharacters

      @NotNull public @NotNull Set<Character> commentCharacters()
      Returns the value of the commentCharacters record component.
      Returns:
      the value of the commentCharacters record component
    • keyPattern

      @NotNull public @NotNull Pattern keyPattern()
      Returns the value of the keyPattern record component.
      Returns:
      the value of the keyPattern record component
    • valuePattern

      @NotNull public @NotNull Pattern valuePattern()
      Returns the value of the valuePattern record component.
      Returns:
      the value of the valuePattern record component
    • advancedParsing

      public boolean advancedParsing()
      Returns the value of the advancedParsing record component.
      Returns:
      the value of the advancedParsing record component
    • charset

      @NotNull public @NotNull Charset charset()
      Returns the value of the charset record component.
      Returns:
      the value of the charset record component