Finding Parent-Cross-Referencer A.K.A Non-Containing-Parents [message #427232] |
Fri, 06 February 2009 21:54 |
Maatari Messages: 4 Registered: July 2009 |
Junior Member |
|
|
As you can see I am stuck with the use of a crossReferencer. I need a
Crossreferencer that is capable of telling me who are the Non-Containing
Parent or the ParentCrossReferencer of that Object. I have Attached the
try I have done, but as you can see, my last attempt pop me out a cast
exeption.
Here the principal problem I have is that I use wrapper. Therefore, The
Object in getChildren are not necessarily EOBJECT. I can Have an object
that wrap represent my referenced object, and therefore are not equal. I
don't know what to do hear? Can anyone suggest me something Please?
/**
* We check that the crossReferencedEObject is within the children of
the referencing Object.
* This method is heavy, it would be better to check the children
feature of the object against the reference.
*/
@SuppressWarnings("unchecked")
@Override
protected boolean crossReference(EObject object, EReference reference,
EObject crossReferencedEObject) {
if (super.crossReference(object, reference, crossReferencedEObject)) {
Collection<EObject> children = mydomain.getChildren(object) == null ?
Collections.EMPTY_LIST : mydomain.getChildren(object) ;
for(EObject child : children) {
if ( EcoreUtil.equals(child, crossReferencedEObject))
return true;
}
}
return false;
}
}
Please does any one has an Idea on how to solve this problem of
ParentCross-Referencer or Non-Containg Parent ?
Many thanks,
Maatari
|
|
|
Re: Finding Parent-Cross-Referencer A.K.A Non-Containing-Parents [message #427236 is a reply to message #427232] |
Sat, 07 February 2009 12:46 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Maatari,
This note of yours was posted only 6 minutes after the previous one...
Maatari wrote:
> As you can see I am stuck with the use of a crossReferencer. I need a
> Crossreferencer that is capable of telling me who are the
> Non-Containing Parent or the ParentCrossReferencer of that Object. I
> have Attached the try I have done, but as you can see, my last attempt
> pop me out a cast exeption.
>
>
> Here the principal problem I have is that I use wrapper. Therefore,
> The Object in getChildren are not necessarily EOBJECT. I can Have an
> object that wrap represent my referenced object, and therefore are not
> equal. I don't know what to do hear? Can anyone suggest me something
> Please?
> /**
> * We check that the crossReferencedEObject is within the
> children of the referencing Object.
> * This method is heavy, it would be better to check the
> children feature of the object against the reference.
> */
> @SuppressWarnings("unchecked")
> @Override
> protected boolean crossReference(EObject object, EReference
> reference, EObject crossReferencedEObject) {
>
> if (super.crossReference(object, reference,
> crossReferencedEObject)) {
>
> Collection<EObject> children =
> mydomain.getChildren(object) == null ? Collections.EMPTY_LIST :
> mydomain.getChildren(object) ;
Does this really return Collection<EObject>? I thought it was
Collection<?> and in fact you're likely getting wrappers returned as
children which aren't EObjects...
>
> for(EObject child : children) {
> if ( EcoreUtil.equals(child, crossReferencedEObject))
> return true;
> }
>
> }
>
> return false;
> }
>
> }
>
>
>
> Please does any one has an Idea on how to solve this problem of
> ParentCross-Referencer or Non-Containg Parent ?
Anyway, as I suggested in the other post, I think you just want to do an
== test on the reference.
>
>
> Many thanks,
> Maatari
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02549 seconds