Class MetricDescriptionUtility


  • public final class MetricDescriptionUtility
    extends Object
    Utility class to handle MetricDescription(s).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends javax.measure.quantity.Quantity>
      javax.measure.unit.Unit<T>
      getDefaultUnit​(org.palladiosimulator.metricspec.NumericalBaseMetricDescription baseMetric, Class<T> quantityDimension)
      Convenience method to get the default unit of a numerical metric description in a typesafe way.
      static boolean isBaseMetricDescriptionSubsumedByMetricDescription​(org.palladiosimulator.metricspec.BaseMetricDescription soughtFor, org.palladiosimulator.metricspec.MetricDescription description)
      Indicates whether a particular base metric description is specified/subsumed by a metric description.
      static boolean isValidValue​(org.palladiosimulator.metricspec.BaseMetricDescription description, Object value)
      Checks if a provided object is valid according to the specified metric.
      static boolean metricDescriptionIdsEqual​(org.palladiosimulator.metricspec.MetricDescription first, org.palladiosimulator.metricspec.MetricDescription second)
      Gets whether the given MetricDescriptions can be considered equal with respect to their ids.
      static org.palladiosimulator.metricspec.BaseMetricDescription[] toBaseMetricDescriptions​(org.palladiosimulator.metricspec.MetricDescription description)
      Returns all base metric descriptions in the order they are specified in a metric description.
    • Method Detail

      • metricDescriptionIdsEqual

        public static boolean metricDescriptionIdsEqual​(org.palladiosimulator.metricspec.MetricDescription first,
                                                        org.palladiosimulator.metricspec.MetricDescription second)
        Gets whether the given MetricDescriptions can be considered equal with respect to their ids.
        Parameters:
        first - A MetricDescription instance.
        second - A MetricDescription instance.
        Returns:
        true whether the ids of the given metric descriptions are equal (i.e., first.getId().equals(second.getId()) yields true), false otherwise.
        Throws:
        IllegalArgumentException - In case either argument is null.
      • getDefaultUnit

        public static <T extends javax.measure.quantity.Quantity> javax.measure.unit.Unit<T> getDefaultUnit​(org.palladiosimulator.metricspec.NumericalBaseMetricDescription baseMetric,
                                                                                                            Class<T> quantityDimension)
        Convenience method to get the default unit of a numerical metric description in a typesafe way.
        Parameters:
        baseMetric - The NumericalBaseMetricDescription whose default unit is to be retrieved.
        quantityDimension - A Class object denoting the expected Quantity of the default unit.
        Returns:
        The default Unit of the given metric description as defined in the meta-model, expressed in the desired quantity.
        Throws:
        ClassCastException - If the dimension of the unit is different from the specified quantity dimension.
        For instance, if Power.class is passed and the actual dimension is Duration, this exception is thrown.
        See Also:
        Unit.asType(Class), NumericalBaseMetricDescription.getDefaultUnit()
      • isBaseMetricDescriptionSubsumedByMetricDescription

        public static boolean isBaseMetricDescriptionSubsumedByMetricDescription​(org.palladiosimulator.metricspec.BaseMetricDescription soughtFor,
                                                                                 org.palladiosimulator.metricspec.MetricDescription description)
        Indicates whether a particular base metric description is specified/subsumed by a metric description.
        Parameters:
        soughtFor - The BaseMetricDescription which is looked for.
        description - An arbitrary MetricDescription that might subsume more than one base metric descriptions.
        Returns:
        true whether the given base metric description is subsumed, false otherwise.
        See Also:
        toBaseMetricDescriptions(MetricDescription)
      • toBaseMetricDescriptions

        public static org.palladiosimulator.metricspec.BaseMetricDescription[] toBaseMetricDescriptions​(org.palladiosimulator.metricspec.MetricDescription description)
        Returns all base metric descriptions in the order they are specified in a metric description.
        Parameters:
        description - The description which is processed.
        Returns:
        Ordered array of base metrics.
      • isValidValue

        public static boolean isValidValue​(org.palladiosimulator.metricspec.BaseMetricDescription description,
                                           Object value)
        Checks if a provided object is valid according to the specified metric.
        Parameters:
        description - The description to use for the validation.
        value - The value to check.
        Returns:
        true if the object has a valid type, false otherwise.