@Test @DisplayName("not allow double registration") void forbidDoubleRegistration() { assertThrows(IllegalStateException.class, () -> register(new ExposedRepository())); }
void register(Repository<?, ?> repository) { checkNotNull(repository); EntityClass<?> entityClass = repository.entityModelClass(); Class<? extends EntityState> stateClass = entityClass.stateClass(); checkNotAlreadyRegistered(stateClass); repositories.put(stateClass, new RepositoryAccess(repository)); }
VisibilityGuard { void register(Repository<?, ?> repository) { checkNotNull(repository); EntityClass<?> entityClass = repository.entityModelClass(); Class<? extends EntityState> stateClass = entityClass.stateClass(); checkNotAlreadyRegistered(stateClass); repositories.put(stateClass, new RepositoryAccess(repository)); } }
VisibilityGuard { void register(Repository<?, ?> repository) { checkNotNull(repository); EntityClass<?> entityClass = repository.entityModelClass(); Class<? extends EntityState> stateClass = entityClass.stateClass(); checkNotAlreadyRegistered(stateClass); repositories.put(stateClass, new RepositoryAccess(repository)); } private  VisibilityGuard(); }
VisibilityGuard { void register(Repository<?, ?> repository) { checkNotNull(repository); EntityClass<?> entityClass = repository.entityModelClass(); Class<? extends EntityState> stateClass = entityClass.stateClass(); checkNotAlreadyRegistered(stateClass); repositories.put(stateClass, new RepositoryAccess(repository)); } private  VisibilityGuard(); Set<TypeName> entityStateTypes(Visibility visibility); }
VisibilityGuard { void register(Repository<?, ?> repository) { checkNotNull(repository); EntityClass<?> entityClass = repository.entityModelClass(); Class<? extends EntityState> stateClass = entityClass.stateClass(); checkNotAlreadyRegistered(stateClass); repositories.put(stateClass, new RepositoryAccess(repository)); } private  VisibilityGuard(); Set<TypeName> entityStateTypes(Visibility visibility);  }