org.mule.modules.vertex.util.VertexEnvelopeBuilder.java Source code

Java tutorial

Introduction

Here is the source code for org.mule.modules.vertex.util.VertexEnvelopeBuilder.java

Source

/**
 * Mule Vertex Connector
 *
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.modules.vertex.util;

import org.mule.modules.utils.MuleSoftException;
import org.mule.modules.vertex.EnumAttr;

import org.apache.commons.beanutils.PropertyUtils;

import vertexinc.o_series.tps._6._0.LoginType;
import vertexinc.o_series.tps._6._0.VertexEnvelope;

/**
 * @author Pablo Diez * @since 14/03/2012
 */
public class VertexEnvelopeBuilder {

    private VertexEnvelope envelope;

    public VertexEnvelopeBuilder() {
        this.envelope = new VertexEnvelope();
    }

    public VertexEnvelopeBuilder withRequest(EnumAttr type, Object request) {
        try {
            PropertyUtils.setSimpleProperty(envelope, type.getRequestAttr(), request);
            return this;
        } catch (Exception e) {
            throw MuleSoftException.soften(e);
        }
    }

    public VertexEnvelope build() {
        return envelope;
    }

    public VertexEnvelopeBuilder withLogin(LoginType login) {
        envelope.setLogin(login);
        return this;
    }
}