Class AbstractMetric

java.lang.Object
org.somox.metrics.abstractmetrics.AbstractMetric
All Implemented Interfaces:
IMetric
Direct Known Subclasses:
AbstractComposedMetric, AbstractCountingMetric, AbstractHierarchyMapping, NameResemblance, SliceLayerArchitectureQuality, SubsystemComponent

public abstract class AbstractMetric extends Object implements IMetric
Abstract base class of all metrics, contains convenience functions and basic method implementations
  • Constructor Details

    • AbstractMetric

      public AbstractMetric()
  • Method Details

    • computeDirected

      public void computeDirected(ClusteringRelation relationToCompute)
      Description copied from interface: IMetric
      Computes the metric for the given clustering relation and stores the value in it
      Specified by:
      computeDirected in interface IMetric
    • getLaunchConfigurationTab

      public MetricTab 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 interface IMetric
    • getMetricParameters

      public ParameterDescriptor[] 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 interface IMetric
      Returns:
      A list of parameter descriptors for the parameters of this metric
    • isCommutative

      public abstract boolean isCommutative()
      Specified by:
      isCommutative in interface IMetric
      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 interface IMetric
      Parameters:
      gastModel - the Root object of the GAST model
      somoxConfiguration - the configuration of the metric computation
      allMetrics - A map of all metrics available in the running SoMoX instance, maps metricID to Metric implementation
      accessGraph - A graph which contains the number of accesses from the source GASTClass to the target GASTClass for all edges in the
      componentToClassHelper - Helper initialized graph
    • internalComputeDirected

      protected abstract void internalComputeDirected(ClusteringRelation relationToCompute)
      Template method to be implemented by subclasses to effectively compute the metric value
      Parameters:
      relationToCompute - The relation to compute
    • checkMetricPostCondition

      protected boolean checkMetricPostCondition(ClusteringRelation relationToCompute)
      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

      protected boolean checkMetricPreCondition(ClusteringRelation relationToCompute)
      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

      protected AccessCacheGraph getAccessGraphCache()
      Returns:
      the accessGraphCache
    • getMetric

      protected IMetric getMetric(Map<MetricID,IMetric> allMetrics, MetricID metricId)
      Helper method used to securely retrieve a metric from a map of metrics
      Parameters:
      allMetrics - Map of metrics and their IDs
      metricId - 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 set
      classes2 - 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 component
      component2 - Second component
      Returns:
      Union of all classes implementing component1 and component2
    • getComponentToClassHelper

      protected ComponentToImplementingClassesHelper getComponentToClassHelper()
      Returns:
      the componentToClassHelper