Home / Class/ ParserBeanAdapter Class — spring-boot Architecture

ParserBeanAdapter Class — spring-boot Architecture

Architecture documentation for the ParserBeanAdapter class in ApplicationConversionService.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java lines 495–524

	static class ParserBeanAdapter extends BeanAdapter<Parser<?>> {

		ParserBeanAdapter(Parser<?> bean, ResolvableType beanType) {
			super(bean, beanType);
		}

		@Override
		protected ResolvableTypePair getResolvableTypePair(ResolvableType[] generics) {
			return new ResolvableTypePair(STRING, generics[0]);
		}

		@Override
		public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
			String text = (String) source;
			return (!StringUtils.hasText(text)) ? null : parse(text);
		}

		private Object parse(String text) {
			try {
				return bean().parse(text, LocaleContextHolder.getLocale());
			}
			catch (IllegalArgumentException ex) {
				throw ex;
			}
			catch (Throwable ex) {
				throw new IllegalArgumentException("Parse attempt failed for value [" + text + "]", ex);
			}
		}

	}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free