Class Properties

java.lang.Object
net.luis.utils.io.data.property.Properties

public class Properties extends Object
Represents a collection of properties.
This class is immutable and is used for reading properties only.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<String,Property>
    The internal map of properties.
    For performance reasons, the properties are stored with their keys as the map key.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Properties(@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 Type
    Method
    Description
    private 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
    equals(Object object)
     
    @NotNull Map<String,Object>
    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
     
    boolean
    hasProperty(@NotNull String key)
    Checks if this instance contains a property with the specified key.
    int
    Returns the number of properties in this instance.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • properties

      private final Map<String,Property> properties
      The internal map of properties.
      For performance reasons, the properties are stored with their keys as the map key.
  • Constructor Details

    • Properties

      public Properties(@NotNull @NotNull List<Property> 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

      public Properties(@NotNull @NotNull Map<String,Property> 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 copy
      subgroup - The subgroup to remove from the key
      Returns:
      The copied property with the subgroup removed from the key
      Throws:
      NullPointerException - If the property is null
      IllegalArgumentException - 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

      @NotNull public @NotNull @Unmodifiable Collection<Property> getProperties()
      Returns an unmodifiable collection of all properties in this instance.
      Returns:
      A collection of all properties
    • hasProperty

      public boolean hasProperty(@NotNull @NotNull String key)
      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

      @Nullable public @Nullable Property getProperty(@NotNull @NotNull String key)
      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

      @NotNull public @NotNull Properties getPropertiesOfSubgroup(@Nullable @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.
      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

      @NotNull public @NotNull Map<String,Object> 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

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object