Public defender methods and static inner classes in interfaces?

David Walend david at walend.net
Mon Aug 23 19:09:05 PDT 2010


Some style questions: Will it be good taste or bad to include static  
inner classes inside interfaces to provide the default implementation  
of public defender methods? For example

public interface Outer {

     public extension void method(Object parameter)
	default Inner.method;

     //more extension methods
...

     public static final class Inner {

         private Inner() {}

         public static void method(Outer outer,Object parameter) {
		//some code
         }
         //more implementations of extension methods
...
     }

}

Does using a static inner class this way run counter to the goal of  
keeping code out of interfaces (mentioned at then end of section 2 in  
the defender method spec)?

What (if anything) is broken if almost all of the methods declared in  
Outer are implemented by Inner?

Thanks,

Dave



More information about the lambda-dev mailing list