Skip to content

Instantly share code, notes, and snippets.

@feoktant
Created June 20, 2017 15:22
Show Gist options
  • Save feoktant/d0cef407d82deb48d7a2b2dea69cb8da to your computer and use it in GitHub Desktop.
Save feoktant/d0cef407d82deb48d7a2b2dea69cb8da to your computer and use it in GitHub Desktop.
public WebConferenceProvider resolve(String providerId) {
VideoProviderEntity providerEntity = VideoProviderEntity.findById(providerId).orElseThrow(() ->
new ServiceInternalException("Cannot resolve provider with id: " + providerId)
);
return applicationContext.getBean(providerEntity.getProviderClass());
}
public static Optional<VideoProviderEntity> findById(String providerId) {
return Stream.of(VideoProviderEntity.values())
.filter(x -> x.getId().equals(providerId))
.findFirst();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment