Package com.prancingdonkey.transformer

Source Code of com.prancingdonkey.transformer.SalesforceQueryResultToCustomerTransformer

package com.prancingdonkey.transformer;

import com.prancingdonkey.model.Customer;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;

import java.util.Map;

public class SalesforceQueryResultToCustomerTransformer extends AbstractTransformer {

    @Override
    protected Object doTransform(Object o, String s) throws TransformerException {
        if (o instanceof Map) {

            Map payload = (Map) o;
            Customer customer = new Customer();
            String[] nameComponents = ((String) payload.get("Name")).split(" ");
            customer.setFirstName(nameComponents[0]);
            customer.setLastName(nameComponents[1]);

            return customer;
        } else {
            throw new TransformerException(this, new ClassCastException());
        }

    }
}
TOP

Related Classes of com.prancingdonkey.transformer.SalesforceQueryResultToCustomerTransformer

TOP
Copyright © 2018 www.massapi.com. 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.