Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » query for class and interface check
query for class and interface check [message #498104] Sat, 14 November 2009 14:01 Go to next message
Eclipse UserFriend
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 #498180 is a reply to message #498104] Sun, 15 November 2009 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Does anybody have an idea?
Re: query for class and interface check [message #498470 is a reply to message #498104] Tue, 17 November 2009 07:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Gilbert

I'm afraid that I cannot understand your question.

Since you are using eClass() you can probably use eSupertypes().

If you formulate your problem as tests that you actually need to do you
may be able to express them in OCL.

Regards

Ed Willink


Gilbert Mirenque wrote:
> 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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

--=-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).&nbsp; It isn't actually an operation, as far as I recall.&nbsp; It returns the direct super-eclasses, which may include &quot;isAbstract&quot; and &quot;isInterface&quot; eclasses.<BR>
<BR>
If you want to get all supertypes, unordered, a convenient way is &quot;eclass-&gt;closure(eSuperTypes)&quot; assuming a variable named &quot;eclass&quot; of type EClass.<BR>
<BR>
To test for non-empty intersection, do eSuperTypes-&gt;asSet() on each EClass and use the Set::intersection(Set(T)) operation.&nbsp; 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>
&gt; 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--
Previous Topic:oclIsUndefined and empty String
Next Topic:how to define operations?
Goto Forum:
  


Current Time: Thu Mar 28 20:37:25 GMT 2024

Powered by FUDForum. Page generated in 0.04390 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top