The virtual field pattern

Brenden Towey brendentowey at gmail.com
Thu Aug 9 10:19:58 PDT 2012


I was thinking that a practical use for this pattern would be, for 
example, the Collections API, like java.util.List:

package java.util;

public interface VirtualList {

   List getDelegateList();

   boolean add( Object o ) default {
     return getDelegateList().add( o );
   }
   ...etc.
}

(Generics omitted for brevity.)  Definitely not a package-private 
interface.  Nor would I personally guess that the more interesting uses 
of the virtual field pattern would be "probably" package-private 
either.  I'd guess they're all public, myself.



On 8/9/2012 10:07 AM, Olexandr Demura wrote:
> No, its not, since VirtualSomething extends P.
> So, its probably package-private interface - will not leak.
>



More information about the lambda-dev mailing list