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 booleanThe field for theadvancedParsingrecord component.private final intThe field for thealignmentrecord component.private final @NotNull CharsetThe field for thecharsetrecord component.The field for thecommentCharactersrecord component.static final PropertyConfigThe default property configuration.
Separator: '='
Alignment: 1
Comment characters: '#'
Key pattern: "^[a-zA-Z0-9._-]+$"
Value pattern: ".*"
Advanced parsing: false
Charset: UTF-8private final @NotNull PatternThe field for thekeyPatternrecord component.private final charThe field for theseparatorrecord component.private final @NotNull PatternThe field for thevaluePatternrecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theadvancedParsingrecord component.intReturns the value of thealignmentrecord component.@NotNull Charsetcharset()Returns the value of thecharsetrecord component.Returns the value of thecommentCharactersrecord component.voidensureKeyMatches(@NotNull String key) Checks whether the given key matches the key pattern.voidensureValueMatches(@NotNull String value) Checks whether the given value matches the value pattern.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull PatternReturns the value of thekeyPatternrecord component.charReturns the value of theseparatorrecord component.final StringtoString()Returns a string representation of this record class.@NotNull PatternReturns the value of thevaluePatternrecord component.
-
Field Details
-
separator
private final char separatorThe field for theseparatorrecord component. -
alignment
private final int alignmentThe field for thealignmentrecord component. -
commentCharacters
The field for thecommentCharactersrecord component. -
keyPattern
The field for thekeyPatternrecord component. -
valuePattern
The field for thevaluePatternrecord component. -
advancedParsing
private final boolean advancedParsingThe field for theadvancedParsingrecord component. -
charset
The field for thecharsetrecord 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 theseparatorrecord component.- Returns:
- the value of the
separatorrecord component
-
alignment
public int alignment()Returns the value of thealignmentrecord component.- Returns:
- the value of the
alignmentrecord component
-
commentCharacters
Returns the value of thecommentCharactersrecord component.- Returns:
- the value of the
commentCharactersrecord component
-
keyPattern
Returns the value of thekeyPatternrecord component.- Returns:
- the value of the
keyPatternrecord component
-
valuePattern
Returns the value of thevaluePatternrecord component.- Returns:
- the value of the
valuePatternrecord component
-
advancedParsing
public boolean advancedParsing()Returns the value of theadvancedParsingrecord component.- Returns:
- the value of the
advancedParsingrecord component
-
charset
Returns the value of thecharsetrecord component.- Returns:
- the value of the
charsetrecord component
-