### Question:
CustomerCore extends Customer { @Override public <T extends Customer> Optional<T> getRole(Role role, Class<T> expectedRole) { return Optional .ofNullable(roles.get(role)) .filter(expectedRole::isInstance) .map(expectedRole::cast); } CustomerCore(); @Override boolean addRole(Role role); @Override boolean hasRole(Role role); @Override boolean remRole(Role role); @Override Optional<T> getRole(Role role, Class<T> expectedRole); @Override String toString();  }### Answer:
@Test public void getRole() { var core = new CustomerCore(); core.addRole(Role.Borrower); var bRole = core.getRole(Role.Borrower, BorrowerRole.class); assertTrue(bRole.isPresent()); var nonRole = core.getRole(Role.Borrower, InvestorRole.class); assertFalse(nonRole.isPresent()); var invRole = core.getRole(Role.Investor, InvestorRole.class); assertFalse(invRole.isPresent()); }