Source:
<code>public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { if (converters.stream() .filter(MappingJackson2HttpMessageConverter.class::isInstance) .map(AbstractJackson2HttpMessageConverter.class::cast) .map(AbstractJackson2HttpMessageConverter::getObjectMapper) .anyMatch(Jackson2HalModule::isAlreadyRegisteredIn)) { return; } MessageSourceAccessor linkRelationMessageSource = this.beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME, MessageSourceAccessor.class); <START> if (this.hypermediaTypes.stream().anyMatch(HypermediaType::isHalBasedMediaType)) { <END> if (this.hypermediaTypes.contains(HypermediaType.HAL)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Arrays.asList(HAL_JSON, HAL_JSON_UTF8), createHalObjectMapper(this.mapper, this.curieProvider, this.relProvider, linkRelationMessageSource, this.halConfiguration))); } if (this.hypermediaTypes.contains(HypermediaType.HAL_FORMS)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Arrays.asList(HAL_FORMS_JSON), createHalFormsObjectMapper(this.mapper, this.curieProvider, this.relProvider, linkRelationMessageSource, this.halFormsConfiguration))); } } if (this.hypermediaTypes.contains(HypermediaType.COLLECTION_JSON)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Arrays.asList(COLLECTION_JSON), createCollectionJsonObjectMapper(this.mapper, linkRelationMessageSource))); } if (this.hypermediaTypes.contains(HypermediaType.UBER)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Arrays.asList(UBER_JSON), createUberObjectMapper(this.mapper))); } }</code><technical_language>This check is duplicated checks, it? If this is for performance reasons I if a) saves scan in negative case adds in positive case. b) if converting hypermediatypes a Set more efficient</technical_language>

Target:
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { if (converters.stream() .filter(AbstractJackson2HttpMessageConverter.class::isInstance) .map(AbstractJackson2HttpMessageConverter.class::cast) .map(AbstractJackson2HttpMessageConverter::getObjectMapper) .anyMatch(Jackson2HalModule::isAlreadyRegisteredIn)) { return; } MessageSourceAccessor linkRelationMessageSource = this.beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME, MessageSourceAccessor.class); if (this.hypermediaTypes.contains(HypermediaType.HAL)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Arrays.asList(HAL_JSON, HAL_JSON_UTF8), createHalObjectMapper(this.mapper, this.curieProvider, this.relProvider, linkRelationMessageSource, this.halConfiguration))); } if (this.hypermediaTypes.contains(HypermediaType.HAL_FORMS)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Collections.singletonList(HAL_FORMS_JSON), createHalFormsObjectMapper(this.mapper, this.curieProvider, this.relProvider, linkRelationMessageSource, this.halFormsConfiguration))); } if (this.hypermediaTypes.contains(HypermediaType.COLLECTION_JSON)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Collections.singletonList(COLLECTION_JSON), createCollectionJsonObjectMapper(this.mapper, linkRelationMessageSource))); } if (this.hypermediaTypes.contains(HypermediaType.UBER)) { converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter( ResourceSupport.class, Collections.singletonList(UBER_JSON), createUberObjectMapper(this.mapper))); } }