net.navasoft.madcoin.backend.services.vo.response.impl.BusinessFailedResponseVO.java Source code

Java tutorial

Introduction

Here is the source code for net.navasoft.madcoin.backend.services.vo.response.impl.BusinessFailedResponseVO.java

Source

/*******************************************************************************
 * Copyright 2014 Juan Diego Navarre Gonzalez
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.navasoft.madcoin.backend.services.vo.response.impl;

import java.lang.reflect.Array;

import net.navasoft.madcoin.backend.services.vo.response.FailedResponseVO;

import org.apache.commons.lang.ArrayUtils;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

/**
 * net.navasoft.madcoin.backend.services.vo.response.impl Class class
 * BusinessFailedResponseVO. Description:
 * 
 * @author Juan Diego Navarre Gonzalez - (${authorMail})
 * @version 1.0
 * @since 24/08/2014 08:10:23 PM
 */
public class BusinessFailedResponseVO implements FailedResponseVO {

    /**
     * lob.
     * 
     * @since 24/08/2014, 08:10:23 PM
     */
    private String lob;

    /**
     * message.
     * 
     * @since 24/08/2014, 08:10:23 PM
     */
    @JsonProperty
    private String message;

    /**
     * tip.
     * 
     * @since 24/08/2014, 08:10:23 PM
     */
    @JsonProperty
    private String tip[];

    /**
     * Sets the error message.
     * 
     * @param errorMessage
     *            the new error message
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    public void setErrorMessage(String errorMessage) {
        message = errorMessage;
    }

    /**
     * Sets the causes.
     * 
     * @param reasons
     *            the new causes
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    public void setCauses(Object... reasons) {
        for (Object reason : reasons) {
            if (reason instanceof String) {
                lob = ((String) reason);
            }
        }
    }

    /**
     * Sets the tip.
     * 
     * @param tips
     *            the new tip
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    public void setTip(String... tips) {
        tip = tips;
    }

    /**
     * Gets the error message.
     * 
     * @return the error message
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    @JsonIgnore
    public String getErrorMessage() {
        return message;
    }

    /**
     * Gets the causes.
     * 
     * @return the causes
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    @JsonIgnore
    public Object[] getCauses() {
        Object[] causes = (Object[]) Array.newInstance(Object.class, 0);
        causes = ArrayUtils.add(causes, lob);
        return causes;
    }

    /**
     * Gets the tip.
     * 
     * @return the tip
     * @since 24/08/2014, 08:10:23 PM
     */
    @Override
    public String[] getTip() {
        return tip;
    }

}