@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);
  }
@Test
  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());
  }