query for class and interface check [message #498104] |
Sat, 14 November 2009 14:01 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
I have a class WeaveMapping which consists of a Pointcut and an Advice.
Both have references to arbitrary other classes (source and target) in
the model. But I have to ensure that the referenced classes are from the
same type. This can be done by the following constraint:
self.pointcut.source.eClass() = self.advice.target.eClass()
But there is one shortcoming. In this way both classes only must have
the same type but not another implementation of an interface. For
example if there is an interface A in the model, having two
implementations B and C. If an instance B will be referenced as source
only another instance of B can be referenced as target. Is it possible
to specify a constraint allowing an instance of C as well? I can imagine
that it is a problem that all classes of a metamodel have the super
interface EObject. Means that the constraint must only allow interfaces
modeled by myself in the metamodel. Is it possible anyhow?
|
|
|
|
|
Re: query for class and interface check [message #498477 is a reply to message #498470] |
Tue, 17 November 2009 08:24 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
Hi Ed,
> Since you are using eClass() you can probably use eSupertypes().
since when does eSupertypes() exist? In Galileo it can't be found here.
And does it return only the direct super classes?
|
|
|
Re: query for class and interface check [message #498587 is a reply to message #498470] |
Tue, 17 November 2009 15:03 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
> Since you are using eClass() you can probably use eSupertypes().
does it return a set of all the super types? If yes, how can I find out
if both set's have non-empty intersection?
|
|
|
Re: query for class and interface check [message #498747 is a reply to message #498587] |
Wed, 18 November 2009 14:11 |
|
--=-NlzpDVK5wymtYkUjOsTc
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, Gilbert,
EClass has always had an eSuperTypes property (I think that's the
spelling). It isn't actually an operation, as far as I recall. It
returns the direct super-eclasses, which may include "isAbstract" and
"isInterface" eclasses.
If you want to get all supertypes, unordered, a convenient way is
"eclass->closure(eSuperTypes)" assuming a variable named "eclass" of
type EClass.
To test for non-empty intersection, do eSuperTypes->asSet() on each
EClass and use the Set::intersection(Set(T)) operation. If you do a
transitive closure of super-types, then that is already a set.
HTH,
Christian
On Tue, 2009-11-17 at 16:03 +0100, Gilbert Mirenque wrote:
> > Since you are using eClass() you can probably use eSupertypes().
> does it return a set of all the super types? If yes, how can I find out
> if both set's have non-empty intersection?
--=-NlzpDVK5wymtYkUjOsTc
Content-Type: text/html; charset="utf-8"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, Gilbert,<BR>
<BR>
EClass has always had an eSuperTypes property (I think that's the spelling). It isn't actually an operation, as far as I recall. It returns the direct super-eclasses, which may include "isAbstract" and "isInterface" eclasses.<BR>
<BR>
If you want to get all supertypes, unordered, a convenient way is "eclass->closure(eSuperTypes)" assuming a variable named "eclass" of type EClass.<BR>
<BR>
To test for non-empty intersection, do eSuperTypes->asSet() on each EClass and use the Set::intersection(Set(T)) operation. If you do a transitive closure of super-types, then that is already a set.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Tue, 2009-11-17 at 16:03 +0100, Gilbert Mirenque wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
> Since you are using eClass() you can probably use eSupertypes().
does it return a set of all the super types? If yes, how can I find out
if both set's have non-empty intersection?
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-NlzpDVK5wymtYkUjOsTc--
|
|
|
Powered by
FUDForum. Page generated in 0.04390 seconds