Package org.apache.sis.metadata
Class HashCode
Computes a hash code for the specified metadata. The hash code is defined as the sum of hash codes
of all non-empty properties, plus the hash code of the interface. This is a similar contract than
Set.hashCode() (except for the interface) and ensures that the hash code value
is insensitive to the ordering of properties.- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.metadata.MetadataVisitor
MetadataVisitor.Filter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe hash code value, returned byMetadataStandard.hashCode(Object)after calculation.private static final ThreadLocal<HashCode>Provider of visitor instances used byMetadataStandard.hashCode(Object).Fields inherited from class org.apache.sis.metadata.MetadataVisitor
SKIP_SIBLINGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final ThreadLocal<HashCode>creator()Returns the thread-local variable that created thisHashCodeinstance.(package private) static HashCodeReturns the visitor for the current thread if it already exists, or creates a new one otherwise.(package private) MetadataVisitor.FilterpreVisit(PropertyAccessor accessor) Resets the hash code to an initial value for a new metadata instance.(package private) Integerresult()Returns the hash code result after visiting all elements in a metadata instance.(package private) ObjectAdds the hash code of the given metadata property value.Methods inherited from class org.apache.sis.metadata.MetadataVisitor
getCurrentPropertyPath, setCurrentProperty, walk
-
Field Details
-
VISITORS
Provider of visitor instances used byMetadataStandard.hashCode(Object). -
code
private int codeThe hash code value, returned byMetadataStandard.hashCode(Object)after calculation.
-
-
Constructor Details
-
HashCode
private HashCode()Instantiated byVISITORSonly.
-
-
Method Details
-
getOrCreate
Returns the visitor for the current thread if it already exists, or creates a new one otherwise. -
creator
Returns the thread-local variable that created thisHashCodeinstance.- Overrides:
creatorin classMetadataVisitor<Integer>
-
preVisit
Resets the hash code to an initial value for a new metadata instance. If another hash code computation was in progress, that code shall be saved before this method is invoked.- Overrides:
preVisitin classMetadataVisitor<Integer>- Parameters:
accessor- contains the standard interface of the metadata for which a hash code value will be computed.- Returns:
MetadataVisitor.Filter.NON_EMPTYsince this visitor is not restricted to writable properties.
-
visit
Adds the hash code of the given metadata property value. Invoking this method may cause recursive calls toHashCodemethods on this visitor instance if the given value is itself another metadata object.- Specified by:
visitin classMetadataVisitor<Integer>- Parameters:
value- the metadata property value for which to add hash code.type- the type of elements. Note that this is not necessarily the type of givenvalueargument if the latter is a collection.- Returns:
null, meaning to not modify the metadata property value.
-
result
Integer result()Returns the hash code result after visiting all elements in a metadata instance.- Overrides:
resultin classMetadataVisitor<Integer>
-