org.springframework.format.AnnotationFormatterFactory Java Examples

The following examples show how to use org.springframework.format.AnnotationFormatterFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormattingConversionServiceFactoryBean.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private void registerFormatters() {
	if (this.formatters != null) {
		for (Object formatter : this.formatters) {
			if (formatter instanceof Formatter<?>) {
				this.conversionService.addFormatter((Formatter<?>) formatter);
			}
			else if (formatter instanceof AnnotationFormatterFactory<?>) {
				this.conversionService.addFormatterForFieldAnnotation((AnnotationFormatterFactory<?>) formatter);
			}
			else {
				throw new IllegalArgumentException(
						"Custom formatters must be implementations of Formatter or AnnotationFormatterFactory");
			}
		}
	}
	if (this.formatterRegistrars != null) {
		for (FormatterRegistrar registrar : this.formatterRegistrars) {
			registrar.registerFormatters(this.conversionService);
		}
	}
}
 
Example #2
Source File: FormattingConversionServiceFactoryBean.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void registerFormatters(FormattingConversionService conversionService) {
	if (this.formatters != null) {
		for (Object formatter : this.formatters) {
			if (formatter instanceof Formatter<?>) {
				conversionService.addFormatter((Formatter<?>) formatter);
			}
			else if (formatter instanceof AnnotationFormatterFactory<?>) {
				conversionService.addFormatterForFieldAnnotation((AnnotationFormatterFactory<?>) formatter);
			}
			else {
				throw new IllegalArgumentException(
						"Custom formatters must be implementations of Formatter or AnnotationFormatterFactory");
			}
		}
	}
	if (this.formatterRegistrars != null) {
		for (FormatterRegistrar registrar : this.formatterRegistrars) {
			registrar.registerFormatters(conversionService);
		}
	}
}
 
Example #3
Source File: FormattingConversionServiceFactoryBean.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void registerFormatters() {
	if (this.formatters != null) {
		for (Object formatter : this.formatters) {
			if (formatter instanceof Formatter<?>) {
				this.conversionService.addFormatter((Formatter<?>) formatter);
			}
			else if (formatter instanceof AnnotationFormatterFactory<?>) {
				this.conversionService.addFormatterForFieldAnnotation((AnnotationFormatterFactory<?>) formatter);
			}
			else {
				throw new IllegalArgumentException(
						"Custom formatters must be implementations of Formatter or AnnotationFormatterFactory");
			}
		}
	}
	if (this.formatterRegistrars != null) {
		for (FormatterRegistrar registrar : this.formatterRegistrars) {
			registrar.registerFormatters(this.conversionService);
		}
	}
}
 
Example #4
Source File: FormattingConversionServiceFactoryBean.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void registerFormatters(FormattingConversionService conversionService) {
	if (this.formatters != null) {
		for (Object formatter : this.formatters) {
			if (formatter instanceof Formatter<?>) {
				conversionService.addFormatter((Formatter<?>) formatter);
			}
			else if (formatter instanceof AnnotationFormatterFactory<?>) {
				conversionService.addFormatterForFieldAnnotation((AnnotationFormatterFactory<?>) formatter);
			}
			else {
				throw new IllegalArgumentException(
						"Custom formatters must be implementations of Formatter or AnnotationFormatterFactory");
			}
		}
	}
	if (this.formatterRegistrars != null) {
		for (FormatterRegistrar registrar : this.formatterRegistrars) {
			registrar.registerFormatters(conversionService);
		}
	}
}
 
Example #5
Source File: FormattingConversionService.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) {
	Class<? extends Annotation> annotationType = getAnnotationType(annotationFormatterFactory);
	if (this.embeddedValueResolver != null && annotationFormatterFactory instanceof EmbeddedValueResolverAware) {
		((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
	}
	Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
	for (Class<?> fieldType : fieldTypes) {
		addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType));
		addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType));
	}
}
 
Example #6
Source File: FormattingConversionService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static Class<? extends Annotation> getAnnotationType(AnnotationFormatterFactory<? extends Annotation> factory) {
	Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
			GenericTypeResolver.resolveTypeArgument(factory.getClass(), AnnotationFormatterFactory.class);
	if (annotationType == null) {
		throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from " +
				"AnnotationFormatterFactory [" + factory.getClass().getName() +
				"]; does the factory parameterize the <A extends Annotation> generic type?");
	}
	return annotationType;
}
 
Example #7
Source File: FormattingConversionService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) {
	Class<? extends Annotation> annotationType = getAnnotationType(annotationFormatterFactory);
	if (this.embeddedValueResolver != null && annotationFormatterFactory instanceof EmbeddedValueResolverAware) {
		((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
	}
	Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
	for (Class<?> fieldType : fieldTypes) {
		addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType));
		addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType));
	}
}
 
Example #8
Source File: FormattingConversionService.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #9
Source File: FormattingConversionService.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #10
Source File: FormattingConversionService.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
static Class<? extends Annotation> getAnnotationType(AnnotationFormatterFactory<? extends Annotation> factory) {
	Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
			GenericTypeResolver.resolveTypeArgument(factory.getClass(), AnnotationFormatterFactory.class);
	if (annotationType == null) {
		throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from " +
				"AnnotationFormatterFactory [" + factory.getClass().getName() +
				"]; does the factory parameterize the <A extends Annotation> generic type?");
	}
	return annotationType;
}
 
Example #11
Source File: FormattingConversionService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) {
	Class<? extends Annotation> annotationType = getAnnotationType(annotationFormatterFactory);
	if (this.embeddedValueResolver != null && annotationFormatterFactory instanceof EmbeddedValueResolverAware) {
		((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
	}
	Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
	for (Class<?> fieldType : fieldTypes) {
		addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType));
		addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType));
	}
}
 
Example #12
Source File: FormattingConversionService.java    From java-technology-stack with MIT License 5 votes vote down vote up
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #13
Source File: FormattingConversionService.java    From java-technology-stack with MIT License 5 votes vote down vote up
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #14
Source File: FormattingConversionService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
static Class<? extends Annotation> getAnnotationType(AnnotationFormatterFactory<? extends Annotation> factory) {
	Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
			GenericTypeResolver.resolveTypeArgument(factory.getClass(), AnnotationFormatterFactory.class);
	if (annotationType == null) {
		throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from " +
				"AnnotationFormatterFactory [" + factory.getClass().getName() +
				"]; does the factory parameterize the <A extends Annotation> generic type?");
	}
	return annotationType;
}
 
Example #15
Source File: FormattingConversionService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) {
	Class<? extends Annotation> annotationType = getAnnotationType(annotationFormatterFactory);
	if (this.embeddedValueResolver != null && annotationFormatterFactory instanceof EmbeddedValueResolverAware) {
		((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
	}
	Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
	for (Class<?> fieldType : fieldTypes) {
		addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType));
		addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType));
	}
}
 
Example #16
Source File: FormattingConversionService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #17
Source File: FormattingConversionService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #18
Source File: FormattingConversionService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
static Class<? extends Annotation> getAnnotationType(AnnotationFormatterFactory<? extends Annotation> factory) {
	Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
			GenericTypeResolver.resolveTypeArgument(factory.getClass(), AnnotationFormatterFactory.class);
	if (annotationType == null) {
		throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from " +
				"AnnotationFormatterFactory [" + factory.getClass().getName() +
				"]; does the factory parameterize the <A extends Annotation> generic type?");
	}
	return annotationType;
}
 
Example #19
Source File: FormattingConversionService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
Example #20
Source File: FormattingConversionService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}