Class ClassInstanceCountSet
java.lang.Object
cruise.umple.compiler.ClassInstanceCountSet
Class to hold the number of class instances for a given umple model
Provides methods/algorithms to calculate the number of class instances
-
Field Summary
FieldsModifier and TypeFieldDescriptionint -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InstanceDiagramResultcomputeInstanceDiagram(UmpleModel model, int linkingFlag, int initialClassCountFlag, int maxIterations, int maxClassCount) voiddelete()booleanReturns true if the diagram has no class instancesdistributeAssociations(int linkingFlag) Using the number of instance of each class, get the associations between the instances.getAllSuperclasses(String classname) Wrapper for getAllSuperclassesRecursive Will return a Set instead of modifying one Will remove the current class from the superclass treevoidgetInstanceCounts(int maxIter, int maxClasses) We can represent the system as a graph problem.Get a set of abstract/interface/singleton/etc...voidinitializeClassCountsConstant(Integer constInt) Set each class initially to a constant amount of instancesvoidinitializeClassCountsRandom(Map<Integer, Double> minimumInstanceProbabilities) Generate the initial class counts randomly.toString()
-
Field Details
-
statusCode
public int statusCode -
instances
-
loopScores
-
-
Constructor Details
-
ClassInstanceCountSet
-
-
Method Details
-
delete
public void delete() -
computeInstanceDiagram
public static InstanceDiagramResult computeInstanceDiagram(UmpleModel model, int linkingFlag, int initialClassCountFlag, int maxIterations, int maxClassCount) -
diagramIsEmpty
public boolean diagramIsEmpty()Returns true if the diagram has no class instances -
getAllSuperclasses
-
getNoPossibleInheritance
Get a set of abstract/interface/singleton/etc... classes that have no possible concrete subclasses for inheritance. These classes are not necessarily errors on their own; but they can become errors. Example: An abstract class with no possible inheritors, but with 0 required instances is valid. -
getInstanceCounts
public void getInstanceCounts(int maxIter, int maxClasses) We can represent the system as a graph problem. Each class is a node, and each association is 2 directed links between the nodes. For every link, the class count at the start multiplied by the multiplicity must be smaller/equal to the class count at the end. If you have the link A 2..4 -> 3..6 B, for every 2..4 As, there must be 3..6 Bs. Thus, we have the following tightest inequality; for every 4 or less As, there must be at at least 3 Bs There can be less As, or more Bs, but this equality must hold true. So for A = 1-4 there are >3 Bs, for A = 5-8 there are >6 Bs Algorithm: Initialize all class counts to their initial value Loop through every association End = max(End, lowerEnd*ceil(Start/UpperStart)) Repeat until no more changes appear Creates a Map of classnames and their minimum class counts -
initializeClassCountsConstant
Set each class initially to a constant amount of instances -
initializeClassCountsRandom
-
distributeAssociations
Using the number of instance of each class, get the associations between the instances. The linkingFlag parameter determines the number of links to create: - 0 Minimum - 1 Maximum - 2 Random Returns an arraylist of AssociationLinkSet, which is a data class -
toString
-
getInstanceCountMap
-
getClassLoopScores
-