org.infai.emo.matcher.impl
Class GenericFeatureComparator

java.lang.Object
  extended by org.infai.emo.matcher.Comparator
      extended by org.infai.emo.matcher.ElementComparator
          extended by 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 org.infai.emo.matcher.Comparator
getName, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

featureToCompare

private java.lang.String featureToCompare
The name of the EStructuralFeature that shall be compared for both elements.

Constructor Detail

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.
Method Detail

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:
  1. both elements donīt got the feature: method returns 1.0
  2. both elements got the feature: the features will be compared an the method will return either 0.0 or 1.0
  3. 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