Package org.springframework.core.convert.converter

Examples of org.springframework.core.convert.converter.ConditionalGenericConverter


              + "]; does the factory parameterize the <A extends Annotation> generic type?");
    }   
    Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();

    for (final Class<?> fieldType : fieldTypes) {
      addConverter(new ConditionalGenericConverter() {
        public Set<ConvertiblePair> getConvertibleTypes() {
          return Collections.singleton(new ConvertiblePair(fieldType, String.class));
        }
        public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
          return (sourceType.getAnnotation(annotationType) != null);
        }
        public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
          Printer<?> printer = annotationFormatterFactory.getPrinter(sourceType.getAnnotation(annotationType), sourceType.getType());
          return new PrinterConverter(fieldType, printer, FormattingConversionService.this).convert(source, sourceType, targetType);
        }
        public String toString() {
          return "@" + annotationType.getName() + " " + fieldType.getName() + " -> " +
              String.class.getName() + ": " + annotationFormatterFactory;
        }
      });
      addConverter(new ConditionalGenericConverter() {
        public Set<ConvertiblePair> getConvertibleTypes() {
          return Collections.singleton(new ConvertiblePair(String.class, fieldType));
        }
        public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
          return (targetType.getAnnotation(annotationType) != null);
View Full Code Here


      ((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
    }

    Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
    for (final Class<?> fieldType : fieldTypes) {
      addConverter(new ConditionalGenericConverter() {
        public Set<ConvertiblePair> getConvertibleTypes() {
          return Collections.singleton(new ConvertiblePair(fieldType, String.class));
        }
        public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
          return (sourceType.getAnnotation(annotationType) != null);
        }
        public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
          FieldFormatterKey key = new FieldFormatterKey(sourceType.getAnnotation(annotationType), fieldType);
          GenericConverter converter = cachedPrinters.get(key);
          if (converter == null) {
            Printer<?> printer = annotationFormatterFactory.getPrinter(key.getAnnotation(), key.getFieldType());
            converter = new PrinterConverter(fieldType, printer, FormattingConversionService.this);
            cachedPrinters.put(key, converter);
          }
          return converter.convert(source, sourceType, targetType);
        }
        public String toString() {
          return "@" + annotationType.getName() + " " + fieldType.getName() + " -> " +
              String.class.getName() + ": " + annotationFormatterFactory;
        }
      });
      addConverter(new ConditionalGenericConverter() {
        public Set<ConvertiblePair> getConvertibleTypes() {
          return Collections.singleton(new ConvertiblePair(String.class, fieldType));
        }
        public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
          return (targetType.getAnnotation(annotationType) != null);
View Full Code Here

TOP

Related Classes of org.springframework.core.convert.converter.ConditionalGenericConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.