com.groupon.messagebus.thrift.api.MessagePayload Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of messagebus-client Show documentation
Show all versions of messagebus-client Show documentation
Java client to use for MessageBus hornetq servers
The newest version!
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.groupon.messagebus.thrift.api;
/*
* Copyright (c) 2013, Groupon, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of GROUPON nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
public class MessagePayload implements TBase, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("MessagePayload");
private static final TField MESSAGE_FORMAT_FIELD_DESC = new TField("messageFormat", TType.I32, (short)1);
private static final TField STRING_PAYLOAD_FIELD_DESC = new TField("stringPayload", TType.STRING, (short)2);
private static final TField BINARY_PAYLOAD_FIELD_DESC = new TField("binaryPayload", TType.STRING, (short)3);
/**
*
* @see MessagePayloadType
*/
public MessagePayloadType messageFormat;
public String stringPayload;
public ByteBuffer binaryPayload;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
/**
*
* @see MessagePayloadType
*/
MESSAGE_FORMAT((short)1, "messageFormat"),
STRING_PAYLOAD((short)2, "stringPayload"),
BINARY_PAYLOAD((short)3, "binaryPayload");
private static final Map byName = new HashMap();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MESSAGE_FORMAT
return MESSAGE_FORMAT;
case 2: // STRING_PAYLOAD
return STRING_PAYLOAD;
case 3: // BINARY_PAYLOAD
return BINARY_PAYLOAD;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE_FORMAT, new FieldMetaData("messageFormat", TFieldRequirementType.REQUIRED,
new EnumMetaData(TType.ENUM, MessagePayloadType.class)));
tmpMap.put(_Fields.STRING_PAYLOAD, new FieldMetaData("stringPayload", TFieldRequirementType.OPTIONAL,
new FieldValueMetaData(TType.STRING)));
tmpMap.put(_Fields.BINARY_PAYLOAD, new FieldMetaData("binaryPayload", TFieldRequirementType.OPTIONAL,
new FieldValueMetaData(TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(MessagePayload.class, metaDataMap);
}
public MessagePayload() {
}
public MessagePayload(
MessagePayloadType messageFormat)
{
this();
this.messageFormat = messageFormat;
}
/**
* Performs a deep copy on other.
*/
public MessagePayload(MessagePayload other) {
if (other.isSetMessageFormat()) {
this.messageFormat = other.messageFormat;
}
if (other.isSetStringPayload()) {
this.stringPayload = other.stringPayload;
}
if (other.isSetBinaryPayload()) {
this.binaryPayload = TBaseHelper.copyBinary(other.binaryPayload);
;
}
}
public MessagePayload deepCopy() {
return new MessagePayload(this);
}
@Override
public void clear() {
this.messageFormat = null;
this.stringPayload = null;
this.binaryPayload = null;
}
/**
*
* @see MessagePayloadType
*/
public MessagePayloadType getMessageFormat() {
return this.messageFormat;
}
/**
*
* @see MessagePayloadType
*/
public MessagePayload setMessageFormat(MessagePayloadType messageFormat) {
this.messageFormat = messageFormat;
return this;
}
public void unsetMessageFormat() {
this.messageFormat = null;
}
/** Returns true if field messageFormat is set (has been asigned a value) and false otherwise */
public boolean isSetMessageFormat() {
return this.messageFormat != null;
}
public void setMessageFormatIsSet(boolean value) {
if (!value) {
this.messageFormat = null;
}
}
public String getStringPayload() {
return this.stringPayload;
}
public MessagePayload setStringPayload(String stringPayload) {
this.stringPayload = stringPayload;
return this;
}
public void unsetStringPayload() {
this.stringPayload = null;
}
/** Returns true if field stringPayload is set (has been asigned a value) and false otherwise */
public boolean isSetStringPayload() {
return this.stringPayload != null;
}
public void setStringPayloadIsSet(boolean value) {
if (!value) {
this.stringPayload = null;
}
}
public byte[] getBinaryPayload() {
setBinaryPayload(TBaseHelper.rightSize(binaryPayload));
return binaryPayload.array();
}
public ByteBuffer BufferForBinaryPayload() {
return binaryPayload;
}
public MessagePayload setBinaryPayload(byte[] binaryPayload) {
setBinaryPayload(ByteBuffer.wrap(binaryPayload));
return this;
}
public MessagePayload setBinaryPayload(ByteBuffer binaryPayload) {
this.binaryPayload = binaryPayload;
return this;
}
public void unsetBinaryPayload() {
this.binaryPayload = null;
}
/** Returns true if field binaryPayload is set (has been asigned a value) and false otherwise */
public boolean isSetBinaryPayload() {
return this.binaryPayload != null;
}
public void setBinaryPayloadIsSet(boolean value) {
if (!value) {
this.binaryPayload = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case MESSAGE_FORMAT:
if (value == null) {
unsetMessageFormat();
} else {
setMessageFormat((MessagePayloadType)value);
}
break;
case STRING_PAYLOAD:
if (value == null) {
unsetStringPayload();
} else {
setStringPayload((String)value);
}
break;
case BINARY_PAYLOAD:
if (value == null) {
unsetBinaryPayload();
} else {
setBinaryPayload((ByteBuffer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE_FORMAT:
return getMessageFormat();
case STRING_PAYLOAD:
return getStringPayload();
case BINARY_PAYLOAD:
return getBinaryPayload();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case MESSAGE_FORMAT:
return isSetMessageFormat();
case STRING_PAYLOAD:
return isSetStringPayload();
case BINARY_PAYLOAD:
return isSetBinaryPayload();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof MessagePayload)
return this.equals((MessagePayload)that);
return false;
}
public boolean equals(MessagePayload that) {
if (that == null)
return false;
boolean this_present_messageFormat = true && this.isSetMessageFormat();
boolean that_present_messageFormat = true && that.isSetMessageFormat();
if (this_present_messageFormat || that_present_messageFormat) {
if (!(this_present_messageFormat && that_present_messageFormat))
return false;
if (!this.messageFormat.equals(that.messageFormat))
return false;
}
boolean this_present_stringPayload = true && this.isSetStringPayload();
boolean that_present_stringPayload = true && that.isSetStringPayload();
if (this_present_stringPayload || that_present_stringPayload) {
if (!(this_present_stringPayload && that_present_stringPayload))
return false;
if (!this.stringPayload.equals(that.stringPayload))
return false;
}
boolean this_present_binaryPayload = true && this.isSetBinaryPayload();
boolean that_present_binaryPayload = true && that.isSetBinaryPayload();
if (this_present_binaryPayload || that_present_binaryPayload) {
if (!(this_present_binaryPayload && that_present_binaryPayload))
return false;
if (!this.binaryPayload.equals(that.binaryPayload))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(MessagePayload other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
MessagePayload typedOther = (MessagePayload)other;
lastComparison = Boolean.valueOf(isSetMessageFormat()).compareTo(typedOther.isSetMessageFormat());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessageFormat()) {
lastComparison = TBaseHelper.compareTo(this.messageFormat, typedOther.messageFormat);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetStringPayload()).compareTo(typedOther.isSetStringPayload());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStringPayload()) {
lastComparison = TBaseHelper.compareTo(this.stringPayload, typedOther.stringPayload);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetBinaryPayload()).compareTo(typedOther.isSetBinaryPayload());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetBinaryPayload()) {
lastComparison = TBaseHelper.compareTo(this.binaryPayload, typedOther.binaryPayload);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // MESSAGE_FORMAT
if (field.type == TType.I32) {
this.messageFormat = MessagePayloadType.findByValue(iprot.readI32());
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // STRING_PAYLOAD
if (field.type == TType.STRING) {
this.stringPayload = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // BINARY_PAYLOAD
if (field.type == TType.STRING) {
this.binaryPayload = iprot.readBinary();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.messageFormat != null) {
oprot.writeFieldBegin(MESSAGE_FORMAT_FIELD_DESC);
oprot.writeI32(this.messageFormat.getValue());
oprot.writeFieldEnd();
}
if (this.stringPayload != null) {
if (isSetStringPayload()) {
oprot.writeFieldBegin(STRING_PAYLOAD_FIELD_DESC);
oprot.writeString(this.stringPayload);
oprot.writeFieldEnd();
}
}
if (this.binaryPayload != null) {
if (isSetBinaryPayload()) {
oprot.writeFieldBegin(BINARY_PAYLOAD_FIELD_DESC);
oprot.writeBinary(this.binaryPayload);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("MessagePayload(");
boolean first = true;
sb.append("messageFormat:");
if (this.messageFormat == null) {
sb.append("null");
} else {
sb.append(this.messageFormat);
}
first = false;
if (isSetStringPayload()) {
if (!first) sb.append(", ");
sb.append("stringPayload:");
if (this.stringPayload == null) {
sb.append("null");
} else {
sb.append(this.stringPayload);
}
first = false;
}
if (isSetBinaryPayload()) {
if (!first) sb.append(", ");
sb.append("binaryPayload:");
if (this.binaryPayload == null) {
sb.append("null");
} else {
TBaseHelper.toString(this.binaryPayload, sb);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
if (messageFormat == null) {
throw new TProtocolException("Required field 'messageFormat' was not present! Struct: " + toString());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy