Package org.moera.lib.crypto
Class Fingerprint
java.lang.Object
org.moera.lib.crypto.Fingerprint
Represents a fingerprint object.
The fingerprint typically includes a version and arbitrary fields.
-
Constructor Summary
ConstructorsConstructorDescriptionFingerprint
(int version) Creates aFingerprint
instance and sets the version field. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsField
(String name) Checks if a field with the specified name exists in the fingerprint.entrySet()
Returns a set view of the name-value pairs contained in this fingerprint.fieldSet()
Retrieves the set of field names stored in this object.void
forEach
(BiConsumer<? super String, ? super Object> action) Performs the given action for each field.Retrieves the value associated with the specified field name.getOrDefault
(String name, Object defaultValue) Retrieves the value associated with the specified name.int
Returns the version associated with the fingerprint.Associates the specified value with the specified field name.
-
Constructor Details
-
Fingerprint
public Fingerprint(int version) Creates aFingerprint
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
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
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 associatedvalue
- 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
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
Retrieves the set of field names stored in this object.- Returns:
- a set of strings representing the names of the fields
-
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
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 fordefaultValue
- 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
Performs the given action for each field.- Parameters:
action
- the action to be performed. It accepts a field name of typeString
and its corresponding value of typeObject
. The action must not benull
.
-