Example usage for org.springframework.util StringUtils arrayToCommaDelimitedString

List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString

Introduction

In this page you can find the example usage for org.springframework.util StringUtils arrayToCommaDelimitedString.

Prototype

public static String arrayToCommaDelimitedString(@Nullable Object[] arr) 

Source Link

Document

Convert a String array into a comma delimited String (i.e., CSV).

Usage

From source file:org.springframework.cloud.config.server.encryption.CipherEnvironmentEncryptor.java

private Environment decrypt(Environment environment, TextEncryptorLocator encryptor) {
    Environment result = new Environment(environment);
    for (PropertySource source : environment.getPropertySources()) {
        Map<Object, Object> map = new LinkedHashMap<Object, Object>(source.getSource());
        for (Map.Entry<Object, Object> entry : new LinkedHashSet<>(map.entrySet())) {
            Object key = entry.getKey();
            String name = key.toString();
            String value = entry.getValue().toString();
            if (value.startsWith("{cipher}")) {
                map.remove(key);//w  w  w. j a  v a  2s. c om
                try {
                    value = value.substring("{cipher}".length());
                    value = encryptor
                            .locate(this.helper.getEncryptorKeys(name,
                                    StringUtils.arrayToCommaDelimitedString(environment.getProfiles()), value))
                            .decrypt(this.helper.stripPrefix(value));
                } catch (Exception e) {
                    value = "<n/a>";
                    name = "invalid." + name;
                    logger.warn(
                            "Cannot decrypt key: " + key + " (" + e.getClass() + ": " + e.getMessage() + ")");
                }
                map.put(name, value);
            }
        }
        result.add(new PropertySource(source.getName(), map));
    }
    return result;
}

From source file:org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.java

protected Environment clean(Environment value) {
    Environment result = new Environment(value.getName(), value.getProfiles(), value.getLabel(), this.version,
            value.getState());//from  ww w.  ja va  2s  .c o  m
    for (PropertySource source : value.getPropertySources()) {
        String name = source.getName();
        if (this.environment.getPropertySources().contains(name)) {
            continue;
        }
        name = name.replace("applicationConfig: [", "");
        name = name.replace("]", "");
        if (this.searchLocations != null) {
            boolean matches = false;
            String normal = name;
            if (normal.startsWith("file:")) {
                normal = StringUtils.cleanPath(new File(normal.substring("file:".length())).getAbsolutePath());
            }
            String profile = result.getProfiles() == null ? null
                    : StringUtils.arrayToCommaDelimitedString(result.getProfiles());
            for (String pattern : getLocations(result.getName(), profile, result.getLabel()).getLocations()) {
                if (!pattern.contains(":")) {
                    pattern = "file:" + pattern;
                }
                if (pattern.startsWith("file:")) {
                    pattern = StringUtils
                            .cleanPath(new File(pattern.substring("file:".length())).getAbsolutePath()) + "/";
                }
                if (logger.isTraceEnabled()) {
                    logger.trace("Testing pattern: " + pattern + " with property source: " + name);
                }
                if (normal.startsWith(pattern) && !normal.substring(pattern.length()).contains("/")) {
                    matches = true;
                    break;
                }
            }
            if (!matches) {
                // Don't include this one: it wasn't matched by our search locations
                if (logger.isDebugEnabled()) {
                    logger.debug("Not adding property source: " + name);
                }
                continue;
            }
        }
        logger.info("Adding property source: " + name);
        result.add(new PropertySource(name, source.getSource()));
    }
    return result;
}

From source file:org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.java

private String[] getArgs(String application, String profile, String label) {
    List<String> list = new ArrayList<String>();
    String config = application;//  ww w.  ja v  a  2  s  .c o m
    if (!config.startsWith("application")) {
        config = "application," + config;
    }
    list.add("--spring.config.name=" + config);
    list.add("--spring.cloud.bootstrap.enabled=false");
    list.add("--encrypt.failOnError=" + this.failOnError);
    list.add("--spring.config.location=" + StringUtils
            .arrayToCommaDelimitedString(getLocations(application, profile, label).getLocations()));
    return list.toArray(new String[0]);
}

From source file:org.springframework.cloud.dataflow.app.utils.ClassloaderUtils.java

/**
 * Creates a ClassLoader for the launched modules by merging the URLs supplied as argument with the URLs that
 * make up the additional classpath of the launched JVM (retrieved from the application classloader), and
 * setting the extension classloader of the JVM as parent, if accessible.
 *
 * @param urls a list of library URLs/*from w  ww .  j  a va 2  s.c om*/
 * @return the resulting classloader
 */
public static ClassLoader createModuleClassloader(URL[] urls) {
    ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
    if (log.isDebugEnabled()) {
        log.debug("systemClassLoader is " + systemClassLoader);
    }
    if (systemClassLoader instanceof URLClassLoader) {
        // add the URLs of the application classloader to the created classloader
        // to compensate for LaunchedURLClassLoader not delegating to parent to retrieve resources
        @SuppressWarnings("resource")
        URLClassLoader systemUrlClassLoader = (URLClassLoader) systemClassLoader;
        URL[] mergedUrls = new URL[urls.length + systemUrlClassLoader.getURLs().length];
        if (log.isDebugEnabled()) {
            log.debug("Original URLs: " + StringUtils.arrayToCommaDelimitedString(urls));
            log.debug("Java Classpath URLs: "
                    + StringUtils.arrayToCommaDelimitedString(systemUrlClassLoader.getURLs()));
        }
        System.arraycopy(urls, 0, mergedUrls, 0, urls.length);
        System.arraycopy(systemUrlClassLoader.getURLs(), 0, mergedUrls, urls.length,
                systemUrlClassLoader.getURLs().length);
        // add the extension classloader as parent to the created context, if accessible
        if (log.isDebugEnabled()) {
            log.debug("Classloader URLs: " + StringUtils.arrayToCommaDelimitedString(mergedUrls));
        }
        return new LaunchedURLClassLoader(mergedUrls, systemUrlClassLoader.getParent());
    }
    return new LaunchedURLClassLoader(urls, systemClassLoader);
}

From source file:org.springframework.cloud.dataflow.server.batch.SimpleJobServiceFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {

    Assert.notNull(dataSource, "DataSource must not be null.");
    Assert.notNull(jobRepository, "JobRepository must not be null.");
    Assert.notNull(jobLocator, "JobLocator must not be null.");
    Assert.notNull(jobLauncher, "JobLauncher must not be null.");
    Assert.notNull(jobExplorer, "JobExplorer must not be null.");

    jdbcTemplate = new JdbcTemplate(dataSource);

    if (incrementerFactory == null) {
        incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource);
    }//  w  ww. j  av a 2  s  .  co m

    if (databaseType == null) {
        databaseType = DatabaseType.fromMetaData(dataSource).name();
        logger.info("No database type set, using meta data indicating: " + databaseType);
    }

    if (lobHandler == null) {
        lobHandler = new DefaultLobHandler();
    }

    if (serializer == null) {
        this.serializer = new Jackson2ExecutionContextStringSerializer();
    }

    Assert.isTrue(incrementerFactory.isSupportedIncrementerType(databaseType), "'" + databaseType
            + "' is an unsupported database type.  The supported database types are "
            + StringUtils.arrayToCommaDelimitedString(incrementerFactory.getSupportedIncrementerTypes()));

}

From source file:org.springframework.cloud.stream.app.http.source.DefaultMixedCaseContentTypeHttpHeaderMapper.java

private void setHttpHeader(HttpHeaders target, String name, Object value) {
    if (ACCEPT.equalsIgnoreCase(name)) {
        if (value instanceof Collection<?>) {
            Collection<?> values = (Collection<?>) value;
            if (!CollectionUtils.isEmpty(values)) {
                List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
                for (Object type : values) {
                    if (type instanceof MediaType) {
                        acceptableMediaTypes.add((MediaType) type);
                    } else if (type instanceof String) {
                        acceptableMediaTypes.addAll(MediaType.parseMediaTypes((String) type));
                    } else {
                        Class<?> clazz = (type != null) ? type.getClass() : null;
                        throw new IllegalArgumentException(
                                "Expected MediaType or String value for 'Accept' header value, but received: "
                                        + clazz);
                    }/*from   w ww .jav a2s.  c o  m*/
                }
                target.setAccept(acceptableMediaTypes);
            }
        } else if (value instanceof MediaType) {
            target.setAccept(Collections.singletonList((MediaType) value));
        } else if (value instanceof String[]) {
            List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
            for (String next : (String[]) value) {
                acceptableMediaTypes.add(MediaType.parseMediaType(next));
            }
            target.setAccept(acceptableMediaTypes);
        } else if (value instanceof String) {
            target.setAccept(MediaType.parseMediaTypes((String) value));
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected MediaType or String value for 'Accept' header value, but received: " + clazz);
        }
    } else if (ACCEPT_CHARSET.equalsIgnoreCase(name)) {
        if (value instanceof Collection<?>) {
            Collection<?> values = (Collection<?>) value;
            if (!CollectionUtils.isEmpty(values)) {
                List<Charset> acceptableCharsets = new ArrayList<Charset>();
                for (Object charset : values) {
                    if (charset instanceof Charset) {
                        acceptableCharsets.add((Charset) charset);
                    } else if (charset instanceof String) {
                        acceptableCharsets.add(Charset.forName((String) charset));
                    } else {
                        Class<?> clazz = (charset != null) ? charset.getClass() : null;
                        throw new IllegalArgumentException(
                                "Expected Charset or String value for 'Accept-Charset' header value, but received: "
                                        + clazz);
                    }
                }
                target.setAcceptCharset(acceptableCharsets);
            }
        } else if (value instanceof Charset[] || value instanceof String[]) {
            List<Charset> acceptableCharsets = new ArrayList<Charset>();
            Object[] values = ObjectUtils.toObjectArray(value);
            for (Object charset : values) {
                if (charset instanceof Charset) {
                    acceptableCharsets.add((Charset) charset);
                } else if (charset instanceof String) {
                    acceptableCharsets.add(Charset.forName((String) charset));
                }
            }
            target.setAcceptCharset(acceptableCharsets);
        } else if (value instanceof Charset) {
            target.setAcceptCharset(Collections.singletonList((Charset) value));
        } else if (value instanceof String) {
            String[] charsets = StringUtils.commaDelimitedListToStringArray((String) value);
            List<Charset> acceptableCharsets = new ArrayList<Charset>();
            for (String charset : charsets) {
                acceptableCharsets.add(Charset.forName(charset.trim()));
            }
            target.setAcceptCharset(acceptableCharsets);
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Charset or String value for 'Accept-Charset' header value, but received: "
                            + clazz);
        }
    } else if (ALLOW.equalsIgnoreCase(name)) {
        if (value instanceof Collection<?>) {
            Collection<?> values = (Collection<?>) value;
            if (!CollectionUtils.isEmpty(values)) {
                Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>();
                for (Object method : values) {
                    if (method instanceof HttpMethod) {
                        allowedMethods.add((HttpMethod) method);
                    } else if (method instanceof String) {
                        allowedMethods.add(HttpMethod.valueOf((String) method));
                    } else {
                        Class<?> clazz = (method != null) ? method.getClass() : null;
                        throw new IllegalArgumentException(
                                "Expected HttpMethod or String value for 'Allow' header value, but received: "
                                        + clazz);
                    }
                }
                target.setAllow(allowedMethods);
            }
        } else {
            if (value instanceof HttpMethod) {
                target.setAllow(Collections.singleton((HttpMethod) value));
            } else if (value instanceof HttpMethod[]) {
                Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>();
                Collections.addAll(allowedMethods, (HttpMethod[]) value);
                target.setAllow(allowedMethods);
            } else if (value instanceof String || value instanceof String[]) {
                String[] values = (value instanceof String[]) ? (String[]) value
                        : StringUtils.commaDelimitedListToStringArray((String) value);
                Set<HttpMethod> allowedMethods = new HashSet<HttpMethod>();
                for (String next : values) {
                    allowedMethods.add(HttpMethod.valueOf(next.trim()));
                }
                target.setAllow(allowedMethods);
            } else {
                Class<?> clazz = (value != null) ? value.getClass() : null;
                throw new IllegalArgumentException(
                        "Expected HttpMethod or String value for 'Allow' header value, but received: " + clazz);
            }
        }
    } else if (CACHE_CONTROL.equalsIgnoreCase(name)) {
        if (value instanceof String) {
            target.setCacheControl((String) value);
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected String value for 'Cache-Control' header value, but received: " + clazz);
        }
    } else if (CONTENT_LENGTH.equalsIgnoreCase(name)) {
        if (value instanceof Number) {
            target.setContentLength(((Number) value).longValue());
        } else if (value instanceof String) {
            target.setContentLength(Long.parseLong((String) value));
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Number or String value for 'Content-Length' header value, but received: "
                            + clazz);
        }
    } else if (MessageHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
        if (value instanceof MediaType) {
            target.setContentType((MediaType) value);
        } else if (value instanceof String) {
            target.setContentType(MediaType.parseMediaType((String) value));
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected MediaType or String value for 'Content-Type' header value, but received: "
                            + clazz);
        }
    } else if (DATE.equalsIgnoreCase(name)) {
        if (value instanceof Date) {
            target.setDate(((Date) value).getTime());
        } else if (value instanceof Number) {
            target.setDate(((Number) value).longValue());
        } else if (value instanceof String) {
            try {
                target.setDate(Long.parseLong((String) value));
            } catch (NumberFormatException e) {
                target.setDate(this.getFirstDate((String) value, DATE));
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Date, Number, or String value for 'Date' header value, but received: " + clazz);
        }
    } else if (ETAG.equalsIgnoreCase(name)) {
        if (value instanceof String) {
            target.setETag((String) value);
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected String value for 'ETag' header value, but received: " + clazz);
        }
    } else if (EXPIRES.equalsIgnoreCase(name)) {
        if (value instanceof Date) {
            target.setExpires(((Date) value).getTime());
        } else if (value instanceof Number) {
            target.setExpires(((Number) value).longValue());
        } else if (value instanceof String) {
            try {
                target.setExpires(Long.parseLong((String) value));
            } catch (NumberFormatException e) {
                target.setExpires(this.getFirstDate((String) value, EXPIRES));
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Date, Number, or String value for 'Expires' header value, but received: "
                            + clazz);
        }
    } else if (IF_MODIFIED_SINCE.equalsIgnoreCase(name)) {
        if (value instanceof Date) {
            target.setIfModifiedSince(((Date) value).getTime());
        } else if (value instanceof Number) {
            target.setIfModifiedSince(((Number) value).longValue());
        } else if (value instanceof String) {
            try {
                target.setIfModifiedSince(Long.parseLong((String) value));
            } catch (NumberFormatException e) {
                target.setIfModifiedSince(this.getFirstDate((String) value, IF_MODIFIED_SINCE));
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Date, Number, or String value for 'If-Modified-Since' header value, but received: "
                            + clazz);
        }
    } else if (IF_UNMODIFIED_SINCE.equalsIgnoreCase(name)) {
        String ifUnmodifiedSinceValue = null;
        if (value instanceof Date) {
            ifUnmodifiedSinceValue = this.formatDate(((Date) value).getTime());
        } else if (value instanceof Number) {
            ifUnmodifiedSinceValue = this.formatDate(((Number) value).longValue());
        } else if (value instanceof String) {
            try {
                ifUnmodifiedSinceValue = this.formatDate(Long.parseLong((String) value));
            } catch (NumberFormatException e) {
                long longValue = this.getFirstDate((String) value, IF_UNMODIFIED_SINCE);
                ifUnmodifiedSinceValue = this.formatDate(longValue);
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Date, Number, or String value for 'If-Unmodified-Since' header value, but received: "
                            + clazz);
        }
        target.set(IF_UNMODIFIED_SINCE, ifUnmodifiedSinceValue);
    } else if (IF_NONE_MATCH.equalsIgnoreCase(name)) {
        if (value instanceof String) {
            target.setIfNoneMatch((String) value);
        } else if (value instanceof String[]) {
            String delmitedString = StringUtils.arrayToCommaDelimitedString((String[]) value);
            target.setIfNoneMatch(delmitedString);
        } else if (value instanceof Collection) {
            Collection<?> values = (Collection<?>) value;
            if (!CollectionUtils.isEmpty(values)) {
                List<String> ifNoneMatchList = new ArrayList<String>();
                for (Object next : values) {
                    if (next instanceof String) {
                        ifNoneMatchList.add((String) next);
                    } else {
                        Class<?> clazz = (next != null) ? next.getClass() : null;
                        throw new IllegalArgumentException(
                                "Expected String value for 'If-None-Match' header value, but received: "
                                        + clazz);
                    }
                }
                target.setIfNoneMatch(ifNoneMatchList);
            }
        }
    } else if (LAST_MODIFIED.equalsIgnoreCase(name)) {
        if (value instanceof Date) {
            target.setLastModified(((Date) value).getTime());
        } else if (value instanceof Number) {
            target.setLastModified(((Number) value).longValue());
        } else if (value instanceof String) {
            try {
                target.setLastModified(Long.parseLong((String) value));
            } catch (NumberFormatException e) {
                target.setLastModified(this.getFirstDate((String) value, LAST_MODIFIED));
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected Date, Number, or String value for 'Last-Modified' header value, but received: "
                            + clazz);
        }
    } else if (LOCATION.equalsIgnoreCase(name)) {
        if (value instanceof URI) {
            target.setLocation((URI) value);
        } else if (value instanceof String) {
            try {
                target.setLocation(new URI((String) value));
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException(e);
            }
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected URI or String value for 'Location' header value, but received: " + clazz);
        }
    } else if (PRAGMA.equalsIgnoreCase(name)) {
        if (value instanceof String) {
            target.setPragma((String) value);
        } else {
            Class<?> clazz = (value != null) ? value.getClass() : null;
            throw new IllegalArgumentException(
                    "Expected String value for 'Pragma' header value, but received: " + clazz);
        }
    } else if (value instanceof String) {
        target.set(name, (String) value);
    } else if (value instanceof String[]) {
        for (String next : (String[]) value) {
            target.add(name, next);
        }
    } else if (value instanceof Iterable<?>) {
        for (Object next : (Iterable<?>) value) {
            String convertedValue = null;
            if (next instanceof String) {
                convertedValue = (String) next;
            } else {
                convertedValue = this.convertToString(value);
            }
            if (StringUtils.hasText(convertedValue)) {
                target.add(name, convertedValue);
            } else {
                logger.warn("Element of the header '" + name + "' with value '" + value
                        + "' will not be set since it is not a String and no Converter is available. "
                        + "Consider registering a Converter with ConversionService (e.g., <int:converter>)");
            }
        }
    } else {
        String convertedValue = this.convertToString(value);
        if (StringUtils.hasText(convertedValue)) {
            target.set(name, convertedValue);
        } else {
            logger.warn("Header '" + name + "' with value '" + value
                    + "' will not be set since it is not a String and no Converter is available. "
                    + "Consider registering a Converter with ConversionService (e.g., <int:converter>)");
        }
    }
}

From source file:org.springframework.data.gemfire.function.GemfireFunctionUtils.java

/**
 * Determine the order position of a an annotated method parameter
 *
 * @param method the {@link Method} instance
 * @param targetAnnotationType the annotation
 * @param requiredTypes an array of valid parameter types for the annotation
 * @return the parameter position or -1 if the annotated parameter is not found
 *//* w  ww . j  a v a 2 s  .c o m*/
public static int getAnnotationParameterPosition(Method method, Class<?> targetAnnotationType,
        Class<?>[] requiredTypes) {

    int position = -1;

    Annotation[][] parameterAnnotations = method.getParameterAnnotations();

    if (parameterAnnotations.length > 0) {
        Class<?>[] parameterTypes = method.getParameterTypes();

        List<Class<?>> requiredTypesList = Arrays.asList(requiredTypes);

        for (int index = 0; index < parameterAnnotations.length; index++) {
            Annotation[] annotations = parameterAnnotations[index];

            if (annotations.length > 0) {
                for (Annotation annotation : annotations) {
                    if (annotation.annotationType().equals(targetAnnotationType)) {
                        Assert.state(position < 0, String.format(
                                "Method %s signature cannot contain more than one parameter annotated with type %s",
                                method.getName(), targetAnnotationType.getName()));

                        boolean isRequiredType = false;

                        for (Class<?> requiredType : requiredTypesList) {
                            if (requiredType.isAssignableFrom(parameterTypes[index])) {
                                isRequiredType = true;
                                break;
                            }
                        }

                        Assert.isTrue(isRequiredType, String.format(
                                "Parameter of type %s annotated with %s must be assignable from one of type %s in method %s",
                                parameterTypes[index], targetAnnotationType.getName(),
                                StringUtils.arrayToCommaDelimitedString(requiredTypes), method.getName()));

                        position = index;
                    }
                }
            }
        }
    }

    return position;
}

From source file:org.springframework.data.hadoop.fs.DistCp.java

private static void invokeCopy(Configuration config, String[] parsedArgs) {
    try {//w  ww .  j av a 2  s . c o m
        log.info("Running DistCp with arguments [" + StringUtils.arrayToCommaDelimitedString(parsedArgs) + "]");
        DistCpOptions inputOptions = OptionsParser.parse(parsedArgs);
        org.apache.hadoop.tools.DistCp distCp = new org.apache.hadoop.tools.DistCp(config, inputOptions);
        distCp.execute();
    } catch (Exception e) {
        throw new HadoopException("Error running DistCp job", e);
    }
}

From source file:org.springframework.data.hadoop.store.event.LoggingListener.java

/**
 * Constructs Logger listener with given level.
 *
 * @param level the level string//w  w w.j  ava  2 s.  c om
 */
public LoggingListener(String level) {
    try {
        this.level = Level.valueOf(level.toUpperCase());
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
                "Invalid log level '" + level + "'. The (case-insensitive) supported values are: "
                        + StringUtils.arrayToCommaDelimitedString(Level.values()));
    }
}

From source file:org.springframework.integration.channel.AbstractMessageChannel.java

private Message<?> convertPayloadIfNecessary(Message<?> message) {
    // first pass checks if the payload type already matches any of the datatypes
    for (Class<?> datatype : this.datatypes) {
        if (datatype.isAssignableFrom(message.getPayload().getClass())) {
            return message;
        }//  w  w w  . j a  va2  s . c  o m
    }
    // second pass applies conversion if possible, attempting datatypes in order
    ConversionService conversionService = this.getConversionService();
    if (conversionService != null) {
        for (Class<?> datatype : this.datatypes) {
            if (conversionService.canConvert(message.getPayload().getClass(), datatype)) {
                Object convertedPayload = conversionService.convert(message.getPayload(), datatype);
                return MessageBuilder.withPayload(convertedPayload).copyHeaders(message.getHeaders()).build();
            }
        }
    }
    throw new MessageDeliveryException(message,
            "Channel '" + this.getComponentName() + "' expected one of the following datataypes ["
                    + StringUtils.arrayToCommaDelimitedString(this.datatypes) + "], but received ["
                    + message.getPayload().getClass() + "]");
}