All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.minlia.rocket.stateful.body.impl.FailureResponseBody Maven / Gradle / Ivy

There is a newer version: 2.0.4.1.RELEASE
Show newest version
/*
 * Copyright © 2016 Minlia (http://oss.minlia.com/license/framework/2016)
 *
 * 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 com.minlia.rocket.stateful.body.impl;

import com.minlia.rocket.stateful.body.ApiResponseBody;
import com.minlia.rocket.stateful.body.StatefulBody;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * @author will
 */
public class FailureResponseBody extends ApiResponseBody {


  public FailureResponseBody() {
    this.setMessage(StatefulBody.FAILURE_MESSAGE);
    this.setCode(StatefulBody.FAILURE);
    this.setStatus(StatefulBody.FAILURE);
    this.setPayload(super.payload);
  }

  public FailureResponseBody(Integer code, Integer status, String message, T payload) {
    super(StatefulBody.FAILURE, StatefulBody.FAILURE, StatefulBody.FAILURE_MESSAGE, payload);
    this.code = code;
    this.status = status;
    this.message = message;
    this.payload = payload;
  }

  public FailureResponseBody(Integer code, Integer status, T payload) {
    super(StatefulBody.FAILURE, StatefulBody.FAILURE, StatefulBody.FAILURE_MESSAGE, (Object) null);
    this.code = code;
    this.status = status;
    this.payload = payload;
  }

  public FailureResponseBody(Integer code, T payload) {
    super(StatefulBody.FAILURE, StatefulBody.FAILURE, StatefulBody.FAILURE_MESSAGE, (Object) null);
    this.code = code;
    this.payload = payload;
  }

  public FailureResponseBody(Integer code) {
    super(StatefulBody.FAILURE, StatefulBody.FAILURE, StatefulBody.FAILURE_MESSAGE, (Object) null);
    this.code = code;
  }

  public FailureResponseBody(T payload) {
    super(StatefulBody.FAILURE, StatefulBody.FAILURE, StatefulBody.FAILURE_MESSAGE, (Object) null);
    this.payload = payload;
  }

  public static  FailureResponseBody.FailureResponseBodyBuilder builder() {
    return new FailureResponseBody.FailureResponseBodyBuilder();
  }

  @Override
  public boolean equals(Object o) {
    return EqualsBuilder.reflectionEquals(this, o);
  }

  @Override
  public int hashCode() {
    return HashCodeBuilder.reflectionHashCode(this, false);
  }

  @Override
  public String toString() {
    return ToStringBuilder.reflectionToString(this);
  }

  public static class FailureResponseBodyBuilder {

    FailureResponseBody instance = null;

    FailureResponseBodyBuilder() {
      instance = new FailureResponseBody();
    }

    public FailureResponseBody build() {
      return instance;
    }

    protected boolean canEqual(Object other) {
      return EqualsBuilder.reflectionEquals(this, other);
    }

    @Override
    public int hashCode() {
      return HashCodeBuilder.reflectionHashCode(this, false);
    }

    @Override
    public String toString() {
      return ToStringBuilder.reflectionToString(this);
    }


    public FailureResponseBody.FailureResponseBodyBuilder code(Integer code) {
      instance.code = code;
      return this;
    }

    public FailureResponseBody.FailureResponseBodyBuilder status(Integer status) {
      instance.status = status;
      return this;
    }

    public FailureResponseBody.FailureResponseBodyBuilder message(String message) {
      instance.message = message;
      return this;
    }

    public FailureResponseBody.FailureResponseBodyBuilder payload(T payload) {
      instance.payload = payload;
      return this;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy