Can someone help me to understand this portion of code? I'm trying to get some config files from database using a dataRepository class that returns an Observable of the config files in a special form ( it was developed by another developer)
final List<LegalBookDescriptor> legalBookDescriptors = dataRepository.findAllConfigFiles(legalBookDescriptorsDir)
.flatMap(new Func1<ConfigFile, Observable<LegalBookDescriptor>>() {
@Override
public Observable<LegalBookDescriptor> call(ConfigFile configFile) {
try {
final LegalBookDescriptor legalBookDescriptor = conversionService.convert(configFile.getContent(), LegalBookDescriptor.class);
LOG.info(String.format("Successfully loaded [Legal Book Descriptor] from file [%s]", configFile.getPath()));
return Observable.just(legalBookDescriptor);
} catch (Exception e) {
LOG.error(String.format("Failed to load [Legal Book Descriptor] from file [%s]", configFile.getPath()), e);
return Observable.empty();
}
}
})
.toList()
.toBlocking()
.single();
if (legalBookDescriptors.isEmpty()) {
LOG.warn(String.format("Hasn't found any valid Legal Book Descriptor file in the root directory [%s].", legalBookDescriptorsDir));
}
Thank you in advance!