Class Fingerprint

java.lang.Object
org.moera.lib.crypto.Fingerprint

public class Fingerprint extends Object
Represents a fingerprint object. The fingerprint typically includes a version and arbitrary fields.
  • Constructor Details

    • Fingerprint

      public Fingerprint(int version)
      Creates a Fingerprint instance and sets the version field.
      Parameters:
      version - the version number to be set for the fingerprint
  • Method Details

    • getVersion

      public int getVersion()
      Returns the version associated with the fingerprint.
      Returns:
      the version
    • get

      public Object get(String name)
      Retrieves the value associated with the specified field name.
      Parameters:
      name - the name of the field whose value is to be retrieved
      Returns:
      the value associated with the specified field name, or null if the field does not exist
    • put

      public Object put(String name, Object value)
      Associates the specified value with the specified field name. If the fingerprint previously contained a mapping for the name, the old value is replaced.
      Parameters:
      name - the name with which the specified value is to be associated
      value - the value to be associated with the specified name
      Returns:
      the previous value associated with the name, or null if there was no mapping for the name
    • containsField

      public boolean containsField(String name)
      Checks if a field with the specified name exists in the fingerprint.
      Parameters:
      name - the name of the field to check
      Returns:
      true if the field exists, false otherwise
    • fieldSet

      public Set<String> fieldSet()
      Retrieves the set of field names stored in this object.
      Returns:
      a set of strings representing the names of the fields
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Returns a set view of the name-value pairs contained in this fingerprint. Each entry in the set represents a mapping between a field name and its value.
      Returns:
      a set of mappings from field names to their associated values
    • getOrDefault

      public Object getOrDefault(String name, Object defaultValue)
      Retrieves the value associated with the specified name. If the name does not exist in the fingerprint, the specified default value is returned.
      Parameters:
      name - the name to look for
      defaultValue - the value to return if the name is not found
      Returns:
      the value associated with the specified name, or the default value if the name is not found
    • forEach

      public void forEach(BiConsumer<? super String,? super Object> action)
      Performs the given action for each field.
      Parameters:
      action - the action to be performed. It accepts a field name of type String and its corresponding value of type Object. The action must not be null.