Re: [macker-user] detect class that implements 2 interfaces
Brought to you by:
barredijkstra,
melquiades
From: Paul C. <can...@po...> - 2005-10-19 18:01:25
|
There's not really an elegant way to do this. It's one of the features on my list. There is a way -- it's just a little klugy: <access-rule> <deny> <from> <include filter="subtype-of" class="Alpha"> <include filter="subtype-of" class="Beta"/> </include> </from> </deny> </access-rule> The problem with that way of doing it is that you get a *bunch* of errors, one for every class that the offending one references! You can also do this: <access-rule> <deny> <from> <include filter="subtype-of" class="Alpha"> <include filter="subtype-of" class="Beta"/> </include> </from> <to class="void"/> </deny> </access-rule> However, I'm not 100% sure that every class is *guaranteed* to reference the primitive type void, so it's conceivable that this might miss one.... In any case, either way is just a hack until I get the next version of Macker out the door. Cheers, Paul On Oct 19, 2005, at 11:18 AM, Etienne Studer wrote: > Hi Paul > > Thanks! > > How can I transform this into a rule that says 'Don't implement > interface Alpha AND interface Beta at the same time'. Basically, > every class may implement interface Alpha or interface Beta, but no > class must implement interface Alpha AND interface Beta at the same > time. I want to detect such "violations". > > I'm sorry that I don't manage to come up with the complete access- > rule myself... Maybe Paul knows howto... > > --Etienne > > > Paul Cantrell wrote: > >> 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! >>> >> ------------------------------------------------------- >> This SF.Net email is sponsored by: >> Power Architecture Resource Center: Free content, downloads, >> discussions, >> and more. http://solutions.newsforge.com/ibmarch.tmpl >> _______________________________________________ >> Macker-user mailing list >> Mac...@li... >> https://lists.sourceforge.net/lists/listinfo/macker-user >> Macker home page: http://innig.net/macker/ >> > > |