org.infai.emo.matcher.impl
Class GenericFeatureComparator
java.lang.Object
org.infai.emo.matcher.Comparator
org.infai.emo.matcher.ElementComparator
org.infai.emo.matcher.impl.GenericFeatureComparator
public class GenericFeatureComparator
- extends ElementComparator
This Comparator is used to compare one specific feature of both elements.
Therefore the feature must be named explicitly.
- Version:
- 1.0.0
- Author:
- Stanley Hillner
- See Also:
ElementComparator
Field Summary |
private java.lang.String |
featureToCompare
The name of the EStructuralFeature that shall be compared for both elements. |
Constructor Summary |
GenericFeatureComparator(java.lang.String featureToCompare)
Constructor initializes an ElementComparator with a special EStructuralFeature that shall be compared separately. |
Method Summary |
double |
compareTo(org.eclipse.emf.ecore.EObject leftElement,
org.eclipse.emf.ecore.EObject rightElement)
Method compares the given EStructuralFeature of both elements. |
java.lang.String |
getFeatureToCompare()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
featureToCompare
private java.lang.String featureToCompare
- The name of the EStructuralFeature that shall be compared for both elements.
GenericFeatureComparator
public GenericFeatureComparator(java.lang.String featureToCompare)
- Constructor initializes an ElementComparator with a special EStructuralFeature that shall be compared separately.
- Parameters:
featureToCompare
- the name of the feature that will be compared.
getFeatureToCompare
public java.lang.String getFeatureToCompare()
- Returns:
- the name of the feature that shall be compared.
compareTo
public double compareTo(org.eclipse.emf.ecore.EObject leftElement,
org.eclipse.emf.ecore.EObject rightElement)
- Method compares the given EStructuralFeature of both elements.
Note: The EStructuralFeature mustn't exist in both elements!
Several cases can occur:
- both elements donīt got the feature: method returns 1.0
- both elements got the feature: the features will be compared an the method will return either 0.0 or 1.0
- only one element got the feature: method returns 0.0
- Specified by:
compareTo
in class Comparator
- Parameters:
leftElement
- the first element to compare with the second one.rightElement
- the second element to compare with the first one.
- Returns:
- This method must return a double value between 0 and 1.0
1.0 stands for a total matching without any differences and 0 means that there are no commonalities. - See Also:
EObject