How to expose a method in an interface without making it public to all classes

前端 未结 5 632
无人共我
无人共我 2021-01-19 18:01

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

5条回答
  •  广开言路
    2021-01-19 18:04

    Today I've encountered same problem. Fortunately I had opportunity to make a superclass instead of interface. Instead of using this:

    internal interface IPhysicalObject extends IIDObject {
    
        function get shape():IShape;
    
    }
    

    I wrote this:

    public class PhysicalObject extends IDObject {
    
        public function PhysicalObject():void {
    
            ...
    
        }
    
        internal function get shape():IShape { ... }
    
    }
    

    Of course it's only possible if classes that implement IPhysicalObject interface do not extend any other class. I think that is another possible solution.

提交回复
热议问题