Новый метод получения репозитория из сервиса

This commit is contained in:
Mark Struchkov 2019-01-21 11:25:42 +03:00
parent cca5a4ad25
commit 06a7131aba
2 changed files with 12 additions and 0 deletions

View File

@ -11,4 +11,6 @@ public interface UnitService {
void addUnitRepository(UnitRepository unitRepository);
UnitRepository getUnitRepository(Class clazz);
}

View File

@ -35,6 +35,16 @@ public class UnitServiceImpl implements UnitService {
unitRepositories.add(unitRepository);
}
@Override
public UnitRepository getUnitRepository(Class clazz) {
for (UnitRepository unitRepository : unitRepositories) {
if (unitRepository.getClass().equals(clazz)) {
return unitRepository;
}
}
return null;
}
}