Class AbstractShapeComparator<T extends ShapeDescriptor>
- java.lang.Object
-
- com.chemaxon.descriptors.alignment.AbstractShapeComparator<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
ShapeComparator<T>
,DescriptorComparator<T>
,Guarded
,Serializable
@Beta @PublicAPI public abstract class AbstractShapeComparator<T extends ShapeDescriptor> extends Object implements ShapeComparator<T>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.chemaxon.descriptors.common.Guarded
Guarded.EnsureThat, Guarded.New
-
-
Constructor Summary
Constructors Constructor Description AbstractShapeComparator(DescriptorGenerator<T> generator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calculateDissimilarity(byte[] target, byte[] query)
Compare two descriptors in serialized form.double
calculateDissimilarity(T target, T query)
Compare two descriptors.double
calculateSimilarity(byte[] target, byte[] query)
Compare two descriptors in serialized form.double
calculateSimilarity(T target, T query)
Compare two descriptors.ShapeComparisonResult
compare(byte[] target, byte[] query)
Compare two descriptors in serialized form.Object
getGuardObject()
Gets the guard object associated to the generated descriptors/utilities.com.google.common.base.Optional<Double>
getLowerBound()
Get lower bound for the similarity/dissimilarity values if such one can be determined.com.chemaxon.descriptors.common.unguarded.UnguardedContext<T,byte[]>
unguardedContext()
Associated unguarded context.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.chemaxon.descriptors.common.DescriptorComparator
getMetricMetadata, getUpperBound
-
Methods inherited from interface com.chemaxon.descriptors.alignment.ShapeComparator
compare
-
-
-
-
Constructor Detail
-
AbstractShapeComparator
public AbstractShapeComparator(DescriptorGenerator<T> generator)
-
-
Method Detail
-
calculateSimilarity
public double calculateSimilarity(byte[] target, byte[] query)
Description copied from interface:DescriptorComparator
Compare two descriptors in serialized form.- Specified by:
calculateSimilarity
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Parameters:
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized form- Returns:
- Similarity result
-
calculateDissimilarity
public double calculateDissimilarity(byte[] target, byte[] query)
Description copied from interface:DescriptorComparator
Compare two descriptors in serialized form.- Specified by:
calculateDissimilarity
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Parameters:
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized form- Returns:
- Dissimilarity result
-
getLowerBound
public com.google.common.base.Optional<Double> getLowerBound()
Description copied from interface:DescriptorComparator
Get lower bound for the similarity/dissimilarity values if such one can be determined.- Specified by:
getLowerBound
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Returns:
- Lower bond if exists; otherwise absent
-
calculateSimilarity
public double calculateSimilarity(T target, T query)
Description copied from interface:DescriptorComparator
Compare two descriptors.Please note that this convenience method wraps
ComparisonResult.getSimilarity()
of comparison result constructed byDescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
- Specified by:
calculateSimilarity
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Parameters:
target
- Target descriptorquery
- Query descriptor- Returns:
- Similarity result
-
calculateDissimilarity
public double calculateDissimilarity(T target, T query)
Description copied from interface:DescriptorComparator
Compare two descriptors.Please note that this convenience method wraps
ComparisonResult.getDissimilarity()
of comparison result constructed byDescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
- Specified by:
calculateDissimilarity
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Parameters:
target
- Target descriptorquery
- Query descriptor- Returns:
- Dissimilarity result
-
compare
public ShapeComparisonResult compare(byte[] target, byte[] query)
Description copied from interface:DescriptorComparator
Compare two descriptors in serialized form.Please note that some implementation might return a result object containing additional data related to the compariosn results. This method's functionality is equivalent to comparing (with
DescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
) deserialized (byDescriptorSerializer.fromByteArray(byte[])
) descriptors.- Specified by:
compare
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Specified by:
compare
in interfaceShapeComparator<T extends ShapeDescriptor>
- Parameters:
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized form- Returns:
- Comparison result wrapper
-
unguardedContext
public com.chemaxon.descriptors.common.unguarded.UnguardedContext<T,byte[]> unguardedContext()
Description copied from interface:DescriptorComparator
Associated unguarded context.- Specified by:
unguardedContext
in interfaceDescriptorComparator<T extends ShapeDescriptor>
- Returns:
- unguarded context
-
getGuardObject
public Object getGuardObject()
Description copied from interface:Guarded
Gets the guard object associated to the generated descriptors/utilities. Note that serialization/deserialization must preserve guard object reference.This method is intended to use only for ensuring the compatibility of manipulated objects.
Implementations might use the associated
DescriptorGenerator
orDescriptorParameters
reference as the guard object, however it is a non recommended practice to use this method to access the associated generator to perform further operations on it.- Specified by:
getGuardObject
in interfaceGuarded
- Returns:
- The guard object, can not be
null
.
-
-