java.lang.Object
net.luis.utils.io.data.property.Properties
Represents a collection of properties.
This class is immutable and is used for reading properties only.
This class is immutable and is used for reading properties only.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe internal map of properties.
For performance reasons, the properties are stored with their keys as the map key. -
Constructor Summary
ConstructorsConstructorDescriptionProperties
(@NotNull List<Property> properties) Constructs a new properties instance from a list of properties.Properties
(@NotNull Map<String, Property> properties) Constructs a new properties instance from a map of properties -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NotNull Property
copyPropertyAndRemoveGroup
(@NotNull Property property, @Nullable String subgroup) Copies a property and removes the specified subgroup from the key.
If the subgroup is null or empty, the property is copied without any changes.boolean
Returns a map of all properties grouped by their subgroups.
The map returned can either contain nested maps or simple key-value pairs.@NotNull @Unmodifiable Collection
<Property> Returns an unmodifiable collection of all properties in this instance.@NotNull Properties
getPropertiesOfSubgroup
(@Nullable String subgroup) Returns all properties that are part of the specified subgroup.
If the subgroup is null or empty, all properties are returned.
The properties are copied and the subgroup is removed from the key.@Nullable Property
getProperty
(@NotNull String key) Returns the property with the specified key or null if no such property exists.int
hashCode()
boolean
hasProperty
(@NotNull String key) Checks if this instance contains a property with the specified key.int
size()
Returns the number of properties in this instance.toString()
-
Field Details
-
properties
The internal map of properties.
For performance reasons, the properties are stored with their keys as the map key.
-
-
Constructor Details
-
Properties
Constructs a new properties instance from a list of properties.- Parameters:
properties
- The list of properties to construct the instance from- Throws:
NullPointerException
- If the list of properties is null
-
Properties
Constructs a new properties instance from a map of properties- Parameters:
properties
- The map of properties to construct the instance from- Throws:
NullPointerException
- If the map of properties is null
-
-
Method Details
-
copyPropertyAndRemoveGroup
@NotNull private static @NotNull Property copyPropertyAndRemoveGroup(@NotNull @NotNull Property property, @Nullable @Nullable String subgroup) Copies a property and removes the specified subgroup from the key.
If the subgroup is null or empty, the property is copied without any changes.- Parameters:
property
- The property to copysubgroup
- The subgroup to remove from the key- Returns:
- The copied property with the subgroup removed from the key
- Throws:
NullPointerException
- If the property is nullIllegalArgumentException
- If the property is not part of the specified subgroup
-
size
public int size()Returns the number of properties in this instance.- Returns:
- The number of properties
-
getProperties
Returns an unmodifiable collection of all properties in this instance.- Returns:
- A collection of all properties
-
hasProperty
Checks if this instance contains a property with the specified key.- Parameters:
key
- The key to check for- Returns:
- True if a property with the specified key exists, otherwise false
- Throws:
NullPointerException
- If the key is null
-
getProperty
Returns the property with the specified key or null if no such property exists.- Parameters:
key
- The key of the property to return- Returns:
- The property with the specified key or null
- Throws:
NullPointerException
- If the key is null
-
getPropertiesOfSubgroup
Returns all properties that are part of the specified subgroup.
If the subgroup is null or empty, all properties are returned.
The properties are copied and the subgroup is removed from the key.- Parameters:
subgroup
- The subgroup to get the properties for- Returns:
- A new properties instance containing all properties that are part of the specified subgroup
-
getGroupedMap
Returns a map of all properties grouped by their subgroups.
The map returned can either contain nested maps or simple key-value pairs.- Returns:
- A map of all properties grouped by their subgroups
-
equals
-
hashCode
public int hashCode() -
toString
-