java.lang.Object
java.lang.Record
net.luis.utils.io.data.property.PropertyConfig
- Record Components:
separator
- The separator between key and valuealignment
- 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 matchvaluePattern
- The pattern that a value must matchadvancedParsing
- 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 Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
The field for theadvancedParsing
record component.private final int
The field for thealignment
record component.private final @NotNull Charset
The field for thecharset
record component.The field for thecommentCharacters
record component.static final PropertyConfig
The default property configuration.
Separator: '='
Alignment: 1
Comment characters: '#'
Key pattern: "^[a-zA-Z0-9._-]+$"
Value pattern: ".*"
Advanced parsing: false
Charset: UTF-8private final @NotNull Pattern
The field for thekeyPattern
record component.private final char
The field for theseparator
record component.private final @NotNull Pattern
The field for thevaluePattern
record component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the value of theadvancedParsing
record component.int
Returns the value of thealignment
record component.@NotNull Charset
charset()
Returns the value of thecharset
record component.Returns the value of thecommentCharacters
record component.void
ensureKeyMatches
(@NotNull String key) Checks whether the given key matches the key pattern.void
ensureValueMatches
(@NotNull String value) Checks whether the given value matches the value pattern.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@NotNull Pattern
Returns the value of thekeyPattern
record component.char
Returns the value of theseparator
record component.final String
toString()
Returns a string representation of this record class.@NotNull Pattern
Returns the value of thevaluePattern
record component.
-
Field Details
-
separator
private final char separatorThe field for theseparator
record component. -
alignment
private final int alignmentThe field for thealignment
record component. -
commentCharacters
The field for thecommentCharacters
record component. -
keyPattern
The field for thekeyPattern
record component. -
valuePattern
The field for thevaluePattern
record component. -
advancedParsing
private final boolean advancedParsingThe field for theadvancedParsing
record component. -
charset
The field for thecharset
record component. -
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 valuealignment
- The number of spaces between key and valuecommentCharacters
- The characters that indicate a comment linekeyPattern
- The pattern that a key must matchvaluePattern
- The pattern that a value must matchadvancedParsing
- Whether to use advanced parsingcharset
- The charset to use for reading and writing- Throws:
NullPointerException
- If any of the parameters is nullIllegalArgumentException
- If the separator is a whitespace character or a comment character
-
-
Method Details
-
ensureKeyMatches
Checks whether the given key matches the key pattern.- Parameters:
key
- The key to check- Throws:
NullPointerException
- If the key is nullPropertySyntaxException
- If the key is blank or does not match the key pattern
-
ensureValueMatches
Checks whether the given value matches the value pattern.- Parameters:
value
- The value to check- Throws:
NullPointerException
- If the value is nullPropertySyntaxException
- If the value does not match the value pattern
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
separator
public char separator()Returns the value of theseparator
record component.- Returns:
- the value of the
separator
record component
-
alignment
public int alignment()Returns the value of thealignment
record component.- Returns:
- the value of the
alignment
record component
-
commentCharacters
Returns the value of thecommentCharacters
record component.- Returns:
- the value of the
commentCharacters
record component
-
keyPattern
Returns the value of thekeyPattern
record component.- Returns:
- the value of the
keyPattern
record component
-
valuePattern
Returns the value of thevaluePattern
record component.- Returns:
- the value of the
valuePattern
record component
-
advancedParsing
public boolean advancedParsing()Returns the value of theadvancedParsing
record component.- Returns:
- the value of the
advancedParsing
record component
-
charset
Returns the value of thecharset
record component.- Returns:
- the value of the
charset
record component
-