This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 94859

Summary: Links with multiplicity ends are not drawn for attributes that have Collection type
Product: uml Reporter: Alexandr Scherbatiy <sunflower>
Component: Reverse EngineeringAssignee: Trey Spiva <tspiva>
Status: VERIFIED FIXED    
Severity: blocker CC: tspiva
Priority: P2    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Aggregation link is not drawn on Class diagram
Class diagram of generic collections.

Description Alexandr Scherbatiy 2007-02-07 15:05:53 UTC
Steps to reproduce:
- Create a Java Application
- Create a 'pack' package
- Add 'A' java class under the package
---------------------------------------------------------
  package pack;
  public class A {
  }
---------------------------------------------------------
- Add 'B' java class under the package
---------------------------------------------------------
package pack;

import java.util.LinkedList;

public class B {
   public LinkedList<A> list = null;
}
---------------------------------------------------------
- Reverse Engineer the Java Application
- Select the 'A' and 'B' elements and invoke 
  'Create Diagram From Selected Elements...'
  and create a Class diagram
  The Aggregation link with multiplicity ends is not drawn
  between 'A' and 'B' (see attached snapshot)
Comment 1 Alexandr Scherbatiy 2007-02-07 15:06:45 UTC
Created attachment 38177 [details]
Aggregation link is not drawn on Class diagram
Comment 2 Trey Spiva 2007-02-07 15:23:14 UTC
Take a look at the image.  You will notice that the aggregation association is not between classes B and A.  
It is between B and the derivation classifier LinkedList < A >.  If you a CDFS between B and the derivation 
classifier you will see the association.
Comment 3 Alexandr Scherbatiy 2007-02-07 15:51:58 UTC
The LinkedList class is not only a Generic class. It is also is
a class from Collection framework.
For example create A and B class on the Class diagram, draw a Navigable
Aggregation link from B to A, set multiplicity ends to '*' near 'A' end
and generate a code. The result will contain the collection type:
-----------------------------------------
public class B {
    private ArrayList<A> mA;
}
-----------------------------------------
So the Reverse Engineering should also create links with multiplicity ends
for collection types.

Or you could also  reverse engineer and create a class diagram
for the following java classes:
-----------------------------------------
public class A {
}
public class B {    
 A [] a;    
}
-----------------------------------------
Comment 4 Trey Spiva 2007-02-07 16:03:00 UTC
LinkedList is a generic class, because you are passing a parameter into decloration of the object.

I understand that you want to have reverse engineering create an association with multiplicity.  That is a 
good idea.  I think we already have an issue with this request.  But this is how the code is currently 
designed.  So, I am going to make this an enhancement.
Comment 5 Trey Spiva 2007-03-09 22:23:23 UTC
Created attachment 39352 [details]
Class diagram of generic collections.
Comment 6 Trey Spiva 2007-03-09 22:24:29 UTC
We are now converting collections to multiplicies.  The following use cases where tested.

public class A
{
    private ArrayList < B > b = new ArrayList < B >();
    private ArrayList < ArrayList < B > > bb = new ArrayList < ArrayList < B > >();
    
    private ArrayList < MyGenric < B >> m = null;
    private ArrayList < ArrayList <MyGenric < B > >> mm = null;
    
    /** Creates a new instance of A */
    public A() {
    }
    
    public void myOp(ArrayList < B > b)
    {
        
    }
    
    public void myOp(ArrayList < ArrayList < B > > b)
    {
        
    }
    
    public void myOp(ArrayList < MyGenric < B > > b)
    {
        
    }
    
    public void myOp(ArrayList < ArrayList < MyGenric < B > > > b)
    {
        
    }
    
    public ArrayList < ArrayList < MyGenric < B > > > myOp()
    {
        
    }
}

public class B
{
}

public class MyGeneric < T>
{
}

See the resulting generic_collections.png image that is attached to this issue.
Comment 7 Trey Spiva 2007-03-09 22:25:26 UTC
forgot to assing the issue to my self
Comment 8 Trey Spiva 2007-03-09 22:26:03 UTC
fixed, and assigned
Comment 9 Trey Spiva 2007-03-14 14:39:45 UTC
This has been moved to NetBeans 5.5 code line as well.
Comment 10 Alexandr Scherbatiy 2007-03-14 15:10:52 UTC
Verified. 
The situation for attributes like 'List<String> list;' is described
in issue 97838 Collections that have members from library are not  shown as
association link with multiplicity after RE