Re: [macker-user] detect class that implements 2 interfaces
Brought to you by:
barredijkstra,
melquiades
From: Paul C. <can...@po...> - 2005-10-19 15:47:59
|
Oops! I realize I forgot to post my reply to Etienne to the list! Sorry. Just use nested includes: <include filter="subtype-of" class="Alpha"> <include filter="subtype-of" class="Beta" /> </include> Read the docs -- nested includes make a boolean AND: http://innig.net/macker/guide/pattern.html#nesting Michael -- I'm not sure your approach below actually works. Perhaps you meant that last pattern to read as follows: <pattern name="classes-implementing-Alpha-and-Beta"> <include filter="subtype-of" class="Alpha" /> <include filter="subtype-of" class="Beta" /> <exclude pattern="classes-implementing-only-Alpha" /> <exclude pattern="classes-implementing-only-Beta" /> </pattern> Regardless, nesting is a *far* simpler way to do this. Cheers, Paul On Oct 19, 2005, at 9:34 AM, Michael Sassin wrote: > Hi > > I found a solution for this a while back that is clunky but will > work. Underlying the idea is that if you have tow sets A and B and > want to now the set of A AND B you can write this also as > > A AND B = (A+B) - ( (A - B) + (B-A) > > The operations "-" and "+" relate to exclude and include operations > in Macker. So, as a result you can express your problem as > > <pattern name="classes-implementing-only-Alpha"> > <include filter="subtype-of" class="Alpha" /> > <exclude filter="subtype-of" class="Beta" /> > </pattern> > > <pattern name="classes-implementing-only-Beta"> > <include filter="subtype-of" class="Beta" /> > <exclude filter="subtype-of" class="Alpha" /> > </pattern> > > <pattern name="classes-implementing-only-Beta"> > <include filter="subtype-of" class="Alpha" /> > <include filter="subtype-of" class="Beta" /> > <include pattern="classes-implementing-only-Alpha" /> > <include pattern="classes-implementing-only-Beta" /> > </pattern> > > Michael On Oct 18, 2005, at 10:12 PM, Etienne Studer wrote: > Hi > > What kind of macker rule do I have to write to detect all classes > that implement interface Alpha AND interface Beta. > > For example, > > class X implements Alpha, Beta { > ... > } > > Thanks for any help. > > --Etienne > > P.S. Btw, macker is awesome and we couldn't be without it anymore! |