Package org.springframework.binding.convert.converters

Examples of org.springframework.binding.convert.converters.ArrayToCollection


        if (!targetClass.isInterface() && Modifier.isAbstract(targetClass.getModifiers())) {
          throw new IllegalArgumentException("Conversion target class [" + targetClass.getName()
              + "] is invalid; cannot convert to abstract collection types--"
              + "request an interface or concrete implementation instead");
        }
        return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToCollection(this));
      }
    }
    if (targetClass.isArray()) {
      if (Collection.class.isAssignableFrom(sourceClass)) {
        Converter collectionToArray = new ReverseConverter(new ArrayToCollection(this));
        return new StaticConversionExecutor(sourceClass, targetClass, collectionToArray);
      } else {
        return new StaticConversionExecutor(sourceClass, targetClass, new ObjectToArray(this));
      }
    }
View Full Code Here


        }
        if (converter.getSourceClass().isAssignableFrom(sourceComponentType)) {
          // type erasure has prevented us from getting the concrete type, this is best we can do for now
          ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType,
              converter.getTargetClass(), converter);
          return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToCollection(
              elementConverter));
        } else if (converter.getTargetClass().isAssignableFrom(sourceComponentType)
            && converter instanceof TwoWayConverter) {
          TwoWayConverter twoWay = (TwoWayConverter) converter;
          ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType,
              converter.getSourceClass(), new ReverseConverter(twoWay));
          return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToCollection(
              elementConverter));
        } else {
          throw new ConversionExecutorNotFoundException(sourceClass, targetClass,
              "Custom ConversionExecutor with id '" + id
                  + "' cannot convert from array an storing elements type ["
                  + sourceComponentType.getName() + "] to a collection of type ["
                  + targetClass.getName() + "]");
        }
      }
    }
    if (targetClass.isArray()) {
      Class<?> targetComponentType = targetClass.getComponentType();
      if (Collection.class.isAssignableFrom(sourceClass)) {
        // type erasure limits us here as well
        if (converter.getTargetClass().isAssignableFrom(targetComponentType)) {
          ConversionExecutor elementConverter = new StaticConversionExecutor(converter.getSourceClass(),
              targetComponentType, converter);
          Converter collectionToArray = new ReverseConverter(new ArrayToCollection(elementConverter));
          return new StaticConversionExecutor(sourceClass, targetClass, collectionToArray);
        } else if (converter.getSourceClass().isAssignableFrom(targetComponentType)
            && converter instanceof TwoWayConverter) {
          TwoWayConverter twoWay = (TwoWayConverter) converter;
          ConversionExecutor elementConverter = new StaticConversionExecutor(converter.getTargetClass(),
              targetComponentType, new ReverseConverter(twoWay));
          Converter collectionToArray = new ReverseConverter(new ArrayToCollection(elementConverter));
          return new StaticConversionExecutor(sourceClass, targetClass, collectionToArray);
        } else {
          throw new ConversionExecutorNotFoundException(sourceClass, targetClass,
              "Custom ConversionExecutor with id '" + id + "' cannot convert from collection of type ["
                  + sourceClass.getName() + "] to an array storing elements of type ["
View Full Code Here

TOP

Related Classes of org.springframework.binding.convert.converters.ArrayToCollection

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.