/* * Copyright 2010-2011 Ning, Inc. * * Ning licenses this file to you 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. */ /** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package com.ning.metrics.eventtracker; import java.util.BitSet; import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; public class Click implements org.apache.thrift.TBase<Click, Click._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Click"); private static final org.apache.thrift.protocol.TField IMPRESSION_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("impression_token", org.apache.thrift.protocol.TType.STRING, (short) 1); private static final org.apache.thrift.protocol.TField DATE_FIELD_DESC = new org.apache.thrift.protocol.TField("date", org.apache.thrift.protocol.TType.I64, (short) 2); private static final org.apache.thrift.protocol.TField USER_AGENT_FIELD_DESC = new org.apache.thrift.protocol.TField("user_agent", org.apache.thrift.protocol.TType.STRING, (short) 3); public String impression_token; public long date; public String user_agent; /** * The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { IMPRESSION_TOKEN((short) 1, "impression_token"), DATE((short) 2, "date"), USER_AGENT((short) 3, "user_agent"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); 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: // IMPRESSION_TOKEN return IMPRESSION_TOKEN; case 2: // DATE return DATE; case 3: // USER_AGENT return USER_AGENT; 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 private static final int __DATE_ISSET_ID = 0; private BitSet __isset_bit_vector = new BitSet(1); public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.IMPRESSION_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("impression_token", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.DATE, new org.apache.thrift.meta_data.FieldMetaData("date", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.USER_AGENT, new org.apache.thrift.meta_data.FieldMetaData("user_agent", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Click.class, metaDataMap); } public Click() { } public Click( String impression_token, long date, String user_agent) { this(); this.impression_token = impression_token; this.date = date; setDateIsSet(true); this.user_agent = user_agent; } /** * Performs a deep copy on <i>other</i>. */ public Click(Click other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetImpression_token()) { this.impression_token = other.impression_token; } this.date = other.date; if (other.isSetUser_agent()) { this.user_agent = other.user_agent; } } public Click deepCopy() { return new Click(this); } @Override public void clear() { this.impression_token = null; setDateIsSet(false); this.date = 0; this.user_agent = null; } public String getImpression_token() { return this.impression_token; } public Click setImpression_token(String impression_token) { this.impression_token = impression_token; return this; } public void unsetImpression_token() { this.impression_token = null; } /** * Returns true if field impression_token is set (has been assigned a value) and false otherwise */ public boolean isSetImpression_token() { return this.impression_token != null; } public void setImpression_tokenIsSet(boolean value) { if (!value) { this.impression_token = null; } } public long getDate() { return this.date; } public Click setDate(long date) { this.date = date; setDateIsSet(true); return this; } public void unsetDate() { __isset_bit_vector.clear(__DATE_ISSET_ID); } /** * Returns true if field date is set (has been assigned a value) and false otherwise */ public boolean isSetDate() { return __isset_bit_vector.get(__DATE_ISSET_ID); } public void setDateIsSet(boolean value) { __isset_bit_vector.set(__DATE_ISSET_ID, value); } public String getUser_agent() { return this.user_agent; } public Click setUser_agent(String user_agent) { this.user_agent = user_agent; return this; } public void unsetUser_agent() { this.user_agent = null; } /** * Returns true if field user_agent is set (has been assigned a value) and false otherwise */ public boolean isSetUser_agent() { return this.user_agent != null; } public void setUser_agentIsSet(boolean value) { if (!value) { this.user_agent = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case IMPRESSION_TOKEN: if (value == null) { unsetImpression_token(); } else { setImpression_token((String) value); } break; case DATE: if (value == null) { unsetDate(); } else { setDate((Long) value); } break; case USER_AGENT: if (value == null) { unsetUser_agent(); } else { setUser_agent((String) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case IMPRESSION_TOKEN: return getImpression_token(); case DATE: return new Long(getDate()); case USER_AGENT: return getUser_agent(); } throw new IllegalStateException(); } /** * Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case IMPRESSION_TOKEN: return isSetImpression_token(); case DATE: return isSetDate(); case USER_AGENT: return isSetUser_agent(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) { return false; } if (that instanceof Click) { return this.equals((Click) that); } return false; } public boolean equals(Click that) { if (that == null) { return false; } boolean this_present_impression_token = true && this.isSetImpression_token(); boolean that_present_impression_token = true && that.isSetImpression_token(); if (this_present_impression_token || that_present_impression_token) { if (!(this_present_impression_token && that_present_impression_token)) { return false; } if (!this.impression_token.equals(that.impression_token)) { return false; } } boolean this_present_date = true; boolean that_present_date = true; if (this_present_date || that_present_date) { if (!(this_present_date && that_present_date)) { return false; } if (this.date != that.date) { return false; } } boolean this_present_user_agent = true && this.isSetUser_agent(); boolean that_present_user_agent = true && that.isSetUser_agent(); if (this_present_user_agent || that_present_user_agent) { if (!(this_present_user_agent && that_present_user_agent)) { return false; } if (!this.user_agent.equals(that.user_agent)) { return false; } } return true; } @Override public int hashCode() { return 0; } public int compareTo(Click other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; Click typedOther = (Click) other; lastComparison = Boolean.valueOf(isSetImpression_token()).compareTo(typedOther.isSetImpression_token()); if (lastComparison != 0) { return lastComparison; } if (isSetImpression_token()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.impression_token, typedOther.impression_token); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetDate()).compareTo(typedOther.isSetDate()); if (lastComparison != 0) { return lastComparison; } if (isSetDate()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.date, typedOther.date); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetUser_agent()).compareTo(typedOther.isSetUser_agent()); if (lastComparison != 0) { return lastComparison; } if (isSetUser_agent()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user_agent, typedOther.user_agent); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField field; iprot.readStructBegin(); while (true) { field = iprot.readFieldBegin(); if (field.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (field.id) { case 1: // IMPRESSION_TOKEN if (field.type == org.apache.thrift.protocol.TType.STRING) { this.impression_token = iprot.readString(); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; case 2: // DATE if (field.type == org.apache.thrift.protocol.TType.I64) { this.date = iprot.readI64(); setDateIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; case 3: // USER_AGENT if (field.type == org.apache.thrift.protocol.TType.STRING) { this.user_agent = iprot.readString(); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; default: org.apache.thrift.protocol.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(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.impression_token != null) { oprot.writeFieldBegin(IMPRESSION_TOKEN_FIELD_DESC); oprot.writeString(this.impression_token); oprot.writeFieldEnd(); } oprot.writeFieldBegin(DATE_FIELD_DESC); oprot.writeI64(this.date); oprot.writeFieldEnd(); if (this.user_agent != null) { oprot.writeFieldBegin(USER_AGENT_FIELD_DESC); oprot.writeString(this.user_agent); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("Click("); boolean first = true; sb.append("impression_token:"); if (this.impression_token == null) { sb.append("null"); } else { sb.append(this.impression_token); } first = false; if (!first) { sb.append(", "); } sb.append("date:"); sb.append(this.date); first = false; if (!first) { sb.append(", "); } sb.append("user_agent:"); if (this.user_agent == null) { sb.append("null"); } else { sb.append(this.user_agent); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } }