Cake pattern with Java8 possible?

With inspiration from other answers I came up with the following (rough) class hierarchy that is similar to the cake pattern in Scala: interface UserRepository { String authenticate(String username, String password); } interface UserRepositoryComponent { UserRepository getUserRepository(); } interface UserServiceComponent extends UserRepositoryComponent { default UserService getUserService() { return new UserService(getUserRepository()); } } class UserService { … Read more

tech