I have a issue where I\'m working with a particular interface for quite a lot of things. However, I have a particular method that I want to be available only to a particular
Sorry to keep answering my own question but... Another possibility, kind of crazy, would be to create a sort of lock and key for the method I want to make private similar to the SingletonEnforcer often used in AS3.
// IThing.as
interface IThing {
function thisMethodIsPublic():void;
function thisMethodShouldOnlyBeVisibleToCertainClasses(key:InternalKey):void;
}
// InternalKey.as
internal class InternalKey {}
This seems like overkill to me but I tested it and it works! Classes external to the InternalKey can see the method but cannot call it. It also guarantees that the interface makes use of the method in question instead of having to typecast to the second interface.
It is also possible to make the second interface be an internal interface instead of using the Internal key.
internal interface IInternalThing extends IThing {
function thisMethodShouldOnlyBeVisibleToCertainClasses():void;
}
Actually, both of these are not exactly what I need because I wanted to make the method exposed to a nested package within the package where IThing would be, so basically I want to use custom namespaces here but I can't. I'm probably going to have to move the classes in the nested package back into the same pacakge as IThing.