Class ClassInstanceCountSet

java.lang.Object
cruise.umple.compiler.ClassInstanceCountSet

public class ClassInstanceCountSet
extends java.lang.Object
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

    Fields 
    Modifier and Type Field Description
    java.util.Map<java.lang.String,​ClassInstanceCount> instances  
    java.util.Map<java.lang.String,​java.lang.Integer> loopScores  
    int statusCode  
  • Constructor Summary

    Constructors 
    Constructor Description
    ClassInstanceCountSet​(UmpleModel aUmpleModel)  
  • Method Summary

    Modifier and Type Method Description
    void delete()  
    boolean diagramIsEmpty()
    Returns true if the diagram has no class instances
    java.util.ArrayList<AssociationLinkSet> distributeAssociations​(int linkingFlag)
    Using the number of instance of each class, get the associations between the instances.
    java.util.Set<java.lang.String> getAllSuperclasses​(java.lang.String classname)
    Wrapper for getAllSuperclassesRecursive Will return a Set instead of modifying one Will remove the current class from the superclass tree
    java.util.Map<java.lang.String,​java.lang.Integer> getClassLoopScores()  
    java.util.Map<java.lang.String,​java.lang.Integer> getInstanceCountMap()  
    void getInstanceCounts​(int maxIter, int maxClasses)
    We can represent the system as a graph problem.
    java.util.Set<java.lang.String> getNoPossibleInheritance()
    Get a set of abstract/interface/singleton/etc...
    void initializeClassCountsConstant​(java.lang.Integer constInt)
    Set each class initially to a constant amount of instances
    void initializeClassCountsRandom​(java.util.Map<java.lang.Integer,​java.lang.Double> minimumInstanceProbabilities)
    Generate the initial class counts randomly.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • delete

      public void delete()
    • diagramIsEmpty

      public boolean diagramIsEmpty()
      Returns true if the diagram has no class instances
    • getAllSuperclasses

      public java.util.Set<java.lang.String> getAllSuperclasses​(java.lang.String classname)
      Wrapper for getAllSuperclassesRecursive Will return a Set instead of modifying one Will remove the current class from the superclass tree
    • getNoPossibleInheritance

      public java.util.Set<java.lang.String> 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

      public void initializeClassCountsConstant​(java.lang.Integer constInt)
      Set each class initially to a constant amount of instances
    • initializeClassCountsRandom

      public void initializeClassCountsRandom​(java.util.Map<java.lang.Integer,​java.lang.Double> minimumInstanceProbabilities)
      Generate the initial class counts randomly. Parameter "minimumInstanceProbabilities" is a map of initial instance counts to their probabilities
    • distributeAssociations

      public java.util.ArrayList<AssociationLinkSet> distributeAssociations​(int linkingFlag)
      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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getInstanceCountMap

      public java.util.Map<java.lang.String,​java.lang.Integer> getInstanceCountMap()
    • getClassLoopScores

      public java.util.Map<java.lang.String,​java.lang.Integer> getClassLoopScores()