isAttribute always returns false [message #1052848] |
Tue, 30 April 2013 13:15  |
Eclipse User |
|
|
|
Hi,
Shouldn't the output of isAttribute be "true" on the following code, or is it that I don't understand the meaning of isAttribute. I'm using UML 4.0.2. Thanks!
Property p = UMLFactory.eINSTANCE.createProperty();
Class c = UMLFactory.eINSTANCE.createClass();
c.getOwnedAttributes().add(p);
System.out.println(c.getAttributes().contains(p)); // true
System.out.println(p.isAttribute(p)); // false
--
Hector
|
|
|
|
Re: isAttribute always returns false [message #1052960 is a reply to message #1052935] |
Wed, 01 May 2013 11:19   |
Eclipse User |
|
|
|
Thanks Ed,
I modified the example to have well formed properties and I still get the same result. Do you know of any case of a non-navigable attribute that would make isAttribute return true?
...
Class car = rootPackage.createOwnedClass("Car", false);
Class gas = rootPackage.createOwnedClass("Gas", false);
PrimitiveType type = rootPackage.createOwnedPrimitiveType("String");
Property name = car.createOwnedAttribute("name", type, 1, 1);
System.out.println(name.isAttribute(name)); // false
Association assoc = car.createAssociation(true,
AggregationKind.NONE_LITERAL, "needs", 0, 1, gas, false,
AggregationKind.NONE_LITERAL, "car", 0, 1);
Property car_needs = assoc.getMemberEnd("needs", gas);
Property gas_car = assoc.getMemberEnd("car", car);
System.out.println(car_needs.isAttribute(car_needs)); //false
System.out.println(gas_car.isAttribute(gas_car)); //false
Thanks.
|
|
|
Re: isAttribute always returns false [message #1052962 is a reply to message #1052960] |
Wed, 01 May 2013 11:23   |
Eclipse User |
|
|
|
Hi
My comment on navigability was just based on reading the code without
following up the specifications of the called routines.
It looks as if the assumption was that no one would call isAttribute for
navigable attributes since that would be redundant. This seems wrong
with respect to UML 2.5; hence my suggestion to raise a Bugzilla.
Regards
Ed Willink
On 01/05/2013 16:19, Hector Chavez wrote:
> Thanks Ed,
>
> I modified the example to have well formed properties and I still get
> the same result. Do you know of any case of a non-navigable attribute
> that would make isAttribute return true?
>
> ..
>
> Class car = rootPackage.createOwnedClass("Car", false);
> Class gas = rootPackage.createOwnedClass("Gas", false);
>
> PrimitiveType type = rootPackage.createOwnedPrimitiveType("String");
> Property name = car.createOwnedAttribute("name", type, 1, 1);
>
> System.out.println(name.isAttribute(name)); // false
>
> Association assoc = car.createAssociation(true,
> AggregationKind.NONE_LITERAL, "needs", 0, 1, gas, false,
> AggregationKind.NONE_LITERAL, "car", 0, 1);
>
> Property car_needs = assoc.getMemberEnd("needs", gas);
> Property gas_car = assoc.getMemberEnd("car", car);
>
> System.out.println(car_needs.isAttribute(car_needs)); //false
> System.out.println(gas_car.isAttribute(gas_car)); //false
>
>
> Thanks.
|
|
|
|
Powered by
FUDForum. Page generated in 0.05014 seconds