org.springframework.context.EmbeddedValueResolverAware#org.springframework.format.AnnotationFormatterFactory源码实例Demo

下面列出了org.springframework.context.EmbeddedValueResolverAware#org.springframework.format.AnnotationFormatterFactory 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
		}
	}
}
 
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);
		}
	}
}
 
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);
		}
	}
}
 
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);
		}
	}
}
 
@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));
	}
}
 
@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;
}
 
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
@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));
	}
}
 
@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;
}
 
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
源代码13 项目: lams   文件: FormattingConversionService.java
@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));
	}
}
 
源代码14 项目: lams   文件: FormattingConversionService.java
@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;
}
 
源代码15 项目: lams   文件: FormattingConversionService.java
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
源代码16 项目: lams   文件: FormattingConversionService.java
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {

	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
@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));
	}
}
 
@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;
}
 
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}
 
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
		AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
	this.annotationType = annotationType;
	this.annotationFormatterFactory = annotationFormatterFactory;
	this.fieldType = fieldType;
}