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 80384 - Generics tag generated for attribute/getter/setter for multiplicity "0..1"
Summary: Generics tag generated for attribute/getter/setter for multiplicity "0..1"
Status: VERIFIED FIXED
Alias: None
Product: uml
Classification: Unclassified
Component: Code Generation (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Craig Conover
URL:
Keywords:
Depends on: 83001
Blocks:
  Show dependency tree
 
Reported: 2006-07-17 04:12 UTC by ossiejhmoore
Modified: 2007-02-08 13:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ossiejhmoore 2006-07-17 04:12:11 UTC
SUMMARY:

When setting an association to Navigable, if the multiplicity is set to one
(either by default or explicitly) the generated attribute and getter do not
include the generic specification for the associated ArrayList.

* Tested on Windows and Linux
* I had Use Generics for Collections turned on.

DETAILS:

How to demonstrate the issue under both Windows XP Pro and Linux...

(1) Create new Java project
(2) Create new UML project using Java Platform Model for the above Java project
(3) Create new Class Diagram.
(4) Add two classes 'A' and 'B'.
(5) Create an association between 'A' and 'B'
(6) Set multiplicity on the 'B' end to '1..*'
(7) Right click the 'A' end of the association, choose [Transform|Navigable].
(8) Right click the 'B' end of the association, choose [Transform|Navigable].
You may need to move the multiplicity label out of the way to do this.
(9) Navigate to code for 'A' and 'B'. Note that 'A' class has the class 'B'
generics tag for the attribue and getter. Note that 'B' class does not have the
class 'A' generics tag for the attribute or getter.
(10) Explicity set multiplicity on the 'B' end to '1' then navigate to code for
'A'. Note that the class 'B' generics tag is now missing.
(11) Explicity set multiplicity on the 'A' end to '0..1' then navigate to code
for 'B'. Note that the class 'A' generics tag is now there for the attribute and
getter.
Comment 1 Peter Lam 2007-01-26 22:57:53 UTC
Result in step 9 is correct. if multiplicity is "1", generic collection should
not be used. As for result in step 11, it's a bug because generic collection
should not be used for "0..1" since this is simply zero or one but no more than
one. I'm changing the summary to reflect this here.
Comment 2 Craig Conover 2007-02-01 07:46:32 UTC
Also, when the assoc is navigable both ways, the element that is set navigable
first ends up with no attrs for the other element.

The multiplicity is now only generating collections/generics for mult's greater
than 1.

Working on missing attrs now.
Comment 3 Craig Conover 2007-02-01 09:55:15 UTC
Still some crazy behavior with nav assoc's, but for the most part, whether to
generate Collections/Generics is working, but the model element is not
generating setters/getters in the diagram with the appropriate multiplicity.
Comment 4 Craig Conover 2007-02-03 02:01:19 UTC
Only one end of a navigable association was being considered. Added code to look
at both ends in case the navigation was bi-directional.
Comment 5 Alexandr Scherbatiy 2007-02-05 13:24:03 UTC
set/get methods are incorrectly generated  when the '*' multiplicity is used.

Steps to reproduce:

- Create a Class diagram
- Put a Class element on the diagram and name it 'A'
- Put a Class element on the diagram and name it 'B'
- Draw a Navigable Aggregation link from 'A' to 'B'
- Set multiplicity on the 'B' end to '*'
- Generate code for the UML project and compile it
  The code is not compiled:
------------------------------------------------------------------
import java.util.ArrayList;

public class A {
    private ArrayList<B> mB;

    public A() {
    }

    public B getB() {
        return mB;
    }

    public void setB(B val) {
        this.mB = val;
    }
} 
------------------------------------------------------------------
incompatible types
found   : java.util.ArrayList<B>
required: B
        return mB;
incompatible types
found   : B
required: java.util.ArrayList<B>
        this.mB = val;
2 errors
Comment 6 Craig Conover 2007-02-06 01:12:49 UTC
Currently working on issue 83001. As a Workaround: always use the property sheet
to update multiplicity for attributes, return types and params, until 83001 is
resolved.
Comment 7 Craig Conover 2007-02-06 18:41:15 UTC
Event firing was being skipped as part of fix for issue 83001. Re-enabling it
corrects the issue.
Comment 8 Alexandr Scherbatiy 2007-02-08 13:45:43 UTC
verified