Record Class KeyValue.Source

java.lang.Object
java.lang.Record
io.jstach.ezkv.kvs.KeyValue.Source
Record Components:
uri - the URI representing the origin of the key-value pair.
reference - an optional key-value pair that this one references.
index - an optional index for ordering.
Enclosing class:
KeyValue

public static record KeyValue.Source(URI uri, @Nullable KeyValue reference, int index) extends Record
Represents the source information for a KeyValue. A Source can indicate where the key-value pair was loaded from, such as a configuration file, system properties, or environment variables. It also supports linking a key-value pair to another one through the reference field.

Fields:

  • uri - The URI representing the origin of the key-value pair.
  • reference - An optional KeyValue that this key-value depends on (e.g., for chained loading).
  • index - A numerical identifier that can be used for ordering or tracking.

Usage Example:

The following example demonstrates creating a source from a URI:
URI fileUri = URI.create("file:///config.properties");
KeyValue.Source source = new KeyValue.Source(fileUri, null, 0);
System.out.println("Source URI: " + source.uri());
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A default, empty source instance used when no specific source information is available.
    static URI
    A constant representing a "null" URI for cases where the source is not specified.
    static final Pattern
    Resource name pattern for validation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty source.
    Source(URI uri, @Nullable KeyValue reference, int index)
    Creates an instance of a Source record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the index record component.
    @Nullable KeyValue
    Returns the value of the reference record component.
    Returns a string representation of this record class.
    uri()
    Returns the value of the uri record component.

    Methods inherited from class java.lang.Object

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

    • NULL_URI

      public static URI NULL_URI
      A constant representing a "null" URI for cases where the source is not specified.
    • EMPTY

      public static KeyValue.Source EMPTY
      A default, empty source instance used when no specific source information is available.
    • RESOURCE_NAME_PATTERN

      static final Pattern RESOURCE_NAME_PATTERN
      Resource name pattern for validation.
  • Constructor Details

    • Source

      public Source()
      Creates an empty source.
      See Also:
    • Source

      public Source(URI uri, @Nullable KeyValue reference, int index)
      Creates an instance of a Source record class.
      Parameters:
      uri - the value for the uri record component
      reference - the value for the reference record component
      index - the value for the index record component
  • Method Details

    • toString

      public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • uri

      public URI uri()
      Returns the value of the uri record component.
      Returns:
      the value of the uri record component
    • reference

      public @Nullable KeyValue reference()
      Returns the value of the reference record component.
      Returns:
      the value of the reference record component
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component