Class AbstractMetric
java.lang.Object
org.somox.metrics.abstractmetrics.AbstractMetric
- All Implemented Interfaces:
IMetric
- Direct Known Subclasses:
AbstractComposedMetric
,AbstractCountingMetric
,AbstractHierarchyMapping
,NameResemblance
,SliceLayerArchitectureQuality
,SubsystemComponent
Abstract base class of all metrics, contains convenience functions and basic method
implementations
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Set<org.emftext.language.java.classifiers.ConcreteClassifier>
calculateUnion
(Set<org.emftext.language.java.classifiers.ConcreteClassifier> classes1, Set<org.emftext.language.java.classifiers.ConcreteClassifier> classes2) Helper method which computes the union of two sets of GASTClassesprotected Set<org.emftext.language.java.classifiers.ConcreteClassifier>
calculateUnion
(ComponentImplementingClassesLink component1, ComponentImplementingClassesLink component2) Helper method which computes the union of the classes implementing the two componentsprotected boolean
checkMetricPostCondition
(ClusteringRelation relationToCompute) Method used to implement a metric postcondition.protected boolean
checkMetricPreCondition
(ClusteringRelation relationToCompute) Method used to implement a metric precondition.void
computeDirected
(ClusteringRelation relationToCompute) Computes the metric for the given clustering relation and stores the value in itprotected AccessCacheGraph
protected ComponentToImplementingClassesHelper
Returns the GUI launch configuration tab that can be used to configure the metric.protected IMetric
Helper method used to securely retrieve a metric from a map of metricsThe parameters needed by this metric for its computation.void
initialize
(Root gastModel, SoMoXConfiguration somoxConfiguration, Map<MetricID, IMetric> allMetrics, org.jgrapht.DirectedGraph<org.emftext.language.java.classifiers.ConcreteClassifier, ClassAccessGraphEdge> accessGraph, ComponentToImplementingClassesHelper componentToClassHelper) Initializes the Metric.protected abstract void
internalComputeDirected
(ClusteringRelation relationToCompute) Template method to be implemented by subclasses to effectively compute the metric valueabstract boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.somox.metrics.IMetric
getMID, isNormalised
-
Constructor Details
-
AbstractMetric
public AbstractMetric()
-
-
Method Details
-
computeDirected
Description copied from interface:IMetric
Computes the metric for the given clustering relation and stores the value in it- Specified by:
computeDirected
in interfaceIMetric
-
getLaunchConfigurationTab
Description copied from interface:IMetric
Returns the GUI launch configuration tab that can be used to configure the metric. Override if the metric supplies a tab- Specified by:
getLaunchConfigurationTab
in interfaceIMetric
-
getMetricParameters
Description copied from interface:IMetric
The parameters needed by this metric for its computation. Parameters will be shown on the UI and their values will be passed to the metric during initialization of the metric- Specified by:
getMetricParameters
in interfaceIMetric
- Returns:
- A list of parameter descriptors for the parameters of this metric
-
isCommutative
public abstract boolean isCommutative()- Specified by:
isCommutative
in interfaceIMetric
- Returns:
- true if the metric gives the same result if firstComponent and secondComponent are swapped
-
initialize
public void initialize(Root gastModel, SoMoXConfiguration somoxConfiguration, Map<MetricID, IMetric> allMetrics, org.jgrapht.DirectedGraph<org.emftext.language.java.classifiers.ConcreteClassifier, ClassAccessGraphEdge> accessGraph, ComponentToImplementingClassesHelper componentToClassHelper) Description copied from interface:IMetric
Initializes the Metric. Must be called before metrics are computed. Should be called again, if the model changed- Specified by:
initialize
in interfaceIMetric
- Parameters:
gastModel
- the Root object of the GAST modelsomoxConfiguration
- the configuration of the metric computationallMetrics
- A map of all metrics available in the running SoMoX instance, maps metricID to Metric implementationaccessGraph
- A graph which contains the number of accesses from the source GASTClass to the target GASTClass for all edges in thecomponentToClassHelper
- Helper initialized graph
-
internalComputeDirected
Template method to be implemented by subclasses to effectively compute the metric value- Parameters:
relationToCompute
- The relation to compute
-
checkMetricPostCondition
Method used to implement a metric postcondition. Used if Somox runs with assertions enabled and helps in debugging the metrics- Parameters:
relationToCompute
- The computed metric relation- Returns:
- true if the postcondition holds
-
checkMetricPreCondition
Method used to implement a metric precondition. Used if Somox runs with assertions enabled and helps in debugging the metrics- Parameters:
relationToCompute
- The computed metric relation- Returns:
- true if the precondition holds
-
getAccessGraphCache
- Returns:
- the accessGraphCache
-
getMetric
Helper method used to securely retrieve a metric from a map of metrics- Parameters:
allMetrics
- Map of metrics and their IDsmetricId
- ID to retrieve- Returns:
- The requested metric
-
calculateUnion
protected Set<org.emftext.language.java.classifiers.ConcreteClassifier> calculateUnion(Set<org.emftext.language.java.classifiers.ConcreteClassifier> classes1, Set<org.emftext.language.java.classifiers.ConcreteClassifier> classes2) Helper method which computes the union of two sets of GASTClasses- Parameters:
classes1
- first setclasses2
- second set- Returns:
- Union of set1 and set2
-
calculateUnion
protected Set<org.emftext.language.java.classifiers.ConcreteClassifier> calculateUnion(ComponentImplementingClassesLink component1, ComponentImplementingClassesLink component2) Helper method which computes the union of the classes implementing the two components- Parameters:
component1
- First componentcomponent2
- Second component- Returns:
- Union of all classes implementing component1 and component2
-
getComponentToClassHelper
- Returns:
- the componentToClassHelper
-