Class ScriptHelper
- java.lang.Object
-
- com.nomagic.magicdraw.modelmetrics.ScriptHelper
-
@OpenApiAll public class ScriptHelper extends java.lang.ObjectHelper methods for calculating metrics.- Since:
- 13.12.5 (15:19)
-
-
Constructor Summary
Constructors Constructor Description ScriptHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublecalcAverageForList(java.util.List<? extends java.lang.Number> items)Calculates average for a list of numbers.static doublecalcPercentage(int all, int covered)Calculates percentage.static java.util.CollectiongetElementsRecursively(Element owningPackage)Returns all elements in a package recursively.static java.util.CollectiongetElementsRecursively(Element owningPackage, Stereotype stereotype)Returns all elements in a package recursively.static java.util.CollectiongetElementsRecursively(java.util.Collection<? extends Element> owningPackages)Returns all elements in given packages recursively.static java.util.CollectiongetElementsRecursively(java.util.Collection<? extends Element> owningPackages, Stereotype stereotype)Returns all elements in given packages recursively.static booleanisParentOf(BaseElement possibleParent, BaseElement possibleChild)Checks if given object is child of given parent object.static booleanisParentOf(java.util.Collection<? extends BaseElement> possibleParents, BaseElement possibleChild)Checks if given object is child of any element in a given list of possible parents.
-
-
-
Method Detail
-
getElementsRecursively
public static java.util.Collection getElementsRecursively(Element owningPackage)
Returns all elements in a package recursively.- Parameters:
owningPackage- package to collect the elements.- Returns:
- all owned elements recursively. The input owningPackage is excluded.
-
getElementsRecursively
public static java.util.Collection getElementsRecursively(java.util.Collection<? extends Element> owningPackages)
Returns all elements in given packages recursively.- Parameters:
owningPackages- collection of packages to collect the elements- Returns:
- all owned elements recursively. Given packages are excluded
-
getElementsRecursively
public static java.util.Collection getElementsRecursively(Element owningPackage, Stereotype stereotype)
Returns all elements in a package recursively.- Parameters:
owningPackage- package to collect the elements.stereotype- stereotype of elements to collect.- Returns:
- all owned elements recursively. The input owningPackage is excluded.
-
getElementsRecursively
public static java.util.Collection getElementsRecursively(java.util.Collection<? extends Element> owningPackages, Stereotype stereotype)
Returns all elements in given packages recursively.- Parameters:
owningPackages- collection of packages to collect the elementsstereotype- stereotype of elements to collect.- Returns:
- all owned elements recursively. Given packages are excluded
-
isParentOf
public static boolean isParentOf(BaseElement possibleParent, BaseElement possibleChild)
Checks if given object is child of given parent object.- Parameters:
possibleParent- possible parentpossibleChild- possible child- Returns:
- true if possibleChild is child of possibleParent.
-
isParentOf
public static boolean isParentOf(java.util.Collection<? extends BaseElement> possibleParents, BaseElement possibleChild)
Checks if given object is child of any element in a given list of possible parents.- Parameters:
possibleParents- possible parentpossibleChild- possible child- Returns:
- true if possibleChild is child of possibleParent.
-
calcPercentage
public static double calcPercentage(int all, int covered)Calculates percentage.- Parameters:
all- denominatorcovered- nominator- Returns:
- percentage value or 0 if denominator <= 0
-
calcAverageForList
public static double calcAverageForList(@CheckForNull java.util.List<? extends java.lang.Number> items)Calculates average for a list of numbers.- Parameters:
items- list of numbers- Returns:
- average value for the given list of numbers or 0 by default
-
-