java.lang.Object
net.luis.utils.io.data.property.Property
- All Implemented Interfaces:
DefaultValueGetter
,ValueGetter
Represents a property with a key and a value.
The key and the value are both strings.
The value can be parsed to different types using the methods provided by this class.
The key and the value are both strings.
The value can be parsed to different types using the methods provided by this class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
@NotNull String
Returns the value which is hold by this object as a string.@NotNull String
getKey()
Returns the key of the property as a string.@NotNull String
Returns the value of the property as a string.int
hashCode()
boolean
isPartOfGroup
(@Nullable String group) Returns whether the key of the property is part of the given group.
A group is a string that ends optionally with a dot.
If the group is empty, the key is always part of the group.
Null will be treated as an empty string.static @NotNull Property
Creates a new property with the given key and value.toString()
@NotNull String
toString
(@NotNull PropertyConfig config) Returns the property as a string with the given configuration.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.luis.utils.util.getter.DefaultValueGetter
getAs, getAsBoolean, getAsByte, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsNumber, getAsShort
Methods inherited from interface net.luis.utils.util.getter.ValueGetter
getAs, getAsBoolean, getAsByte, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsNumber, getAsShort
-
Field Details
-
key
The key of the property. -
value
The value of the property.
-
-
Constructor Details
-
Property
Constructs a new property with the given key and value.- Parameters:
key
- The key of the propertyvalue
- The value of the property- Throws:
NullPointerException
- If the key or the value is null
-
-
Method Details
-
of
@NotNull public static @NotNull Property of(@NotNull @NotNull String key, @NotNull @NotNull String value) Creates a new property with the given key and value.- Parameters:
key
- The key of the propertyvalue
- The value of the property- Returns:
- A new property
- Throws:
NullPointerException
- If the key or the value is null
-
getKey
Returns the key of the property as a string.- Returns:
- The key of the property
-
getRawValue
Returns the value of the property as a string.- Returns:
- The value of the property
-
getAsString
Returns the value which is hold by this object as a string.
This method is equivalent togetRawValue()
.- Specified by:
getAsString
in interfaceValueGetter
- Returns:
- The value of the property
-
isPartOfGroup
Returns whether the key of the property is part of the given group.
A group is a string that ends optionally with a dot.
If the group is empty, the key is always part of the group.
Null will be treated as an empty string.
Examples:
Property property = Property.of("this.is.an.example.key", "value"); property.isPartOfGroup(null); // true property.isPartOfGroup(""); // true property.isPartOfGroup("this"); // true property.isPartOfGroup("this.is"); // true property.isPartOfGroup("this.is.an.example.key"); // false -> 'key' is not part of the group, it is the key itself property.isPartOfGroup("some.other.group"); // false
- Parameters:
group
- The group to check- Returns:
- Whether the key is part of the group or not
- Throws:
IllegalArgumentException
- If the group is blank or starts with a dot
-
equals
-
hashCode
public int hashCode() -
toString
-
toString
Returns the property as a string with the given configuration.- Parameters:
config
- The configuration to use- Returns:
- The property as a string
- Throws:
NullPointerException
- If the configuration is null
-