Package org.palladiosimulator.edp2.util
Class MetricDescriptionUtility
java.lang.Object
org.palladiosimulator.edp2.util.MetricDescriptionUtility
Utility class to handle MetricDescription(s).
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 givenMetricDescription
s 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 Details
-
metricDescriptionIdsEqual
public static boolean metricDescriptionIdsEqual(org.palladiosimulator.metricspec.MetricDescription first, org.palladiosimulator.metricspec.MetricDescription second) Gets whether the givenMetricDescription
s can be considered equal with respect to their ids.- Parameters:
first
- AMetricDescription
instance.second
- AMetricDescription
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 isnull
.
-
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
- TheNumericalBaseMetricDescription
whose default unit is to be retrieved.quantityDimension
- AClass
object denoting the expectedQuantity
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, ifPower.class
is passed and the actual dimension isDuration
, 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
- TheBaseMetricDescription
which is looked for.description
- An arbitraryMetricDescription
that might subsume more than one base metric descriptions.- Returns:
true
whether the given base metric description is subsumed,false
otherwise.- See Also:
-
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.
-