/** * Autogenerated by Thrift Compiler (0.9.2) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package com.xiaomi.infra.galaxy.metrics.thrift; import libthrift091.scheme.IScheme; import libthrift091.scheme.SchemeFactory; import libthrift091.scheme.StandardScheme; import libthrift091.scheme.TupleScheme; import libthrift091.protocol.TTupleProtocol; import libthrift091.protocol.TProtocolException; import libthrift091.EncodingUtils; import libthrift091.TException; import libthrift091.async.AsyncMethodCallback; import libthrift091.server.AbstractNonblockingServer.*; 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 javax.annotation.Generated; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) @Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-12-30") public class AlertRule implements libthrift091.TBase<AlertRule, AlertRule._Fields>, java.io.Serializable, Cloneable, Comparable<AlertRule> { private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("AlertRule"); private static final libthrift091.protocol.TField RULE_KEY_FIELD_DESC = new libthrift091.protocol.TField("ruleKey", libthrift091.protocol.TType.STRUCT, (short)1); private static final libthrift091.protocol.TField EMAILS_FIELD_DESC = new libthrift091.protocol.TField("emails", libthrift091.protocol.TType.LIST, (short)2); private static final libthrift091.protocol.TField PHONES_FIELD_DESC = new libthrift091.protocol.TField("phones", libthrift091.protocol.TType.LIST, (short)3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new AlertRuleStandardSchemeFactory()); schemes.put(TupleScheme.class, new AlertRuleTupleSchemeFactory()); } public AlertRuleKey ruleKey; // optional public List<String> emails; // optional public List<String> phones; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements libthrift091.TFieldIdEnum { RULE_KEY((short)1, "ruleKey"), EMAILS((short)2, "emails"), PHONES((short)3, "phones"); 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: // RULE_KEY return RULE_KEY; case 2: // EMAILS return EMAILS; case 3: // PHONES return PHONES; 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 _Fields optionals[] = {_Fields.RULE_KEY,_Fields.EMAILS,_Fields.PHONES}; public static final Map<_Fields, libthrift091.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, libthrift091.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, libthrift091.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.RULE_KEY, new libthrift091.meta_data.FieldMetaData("ruleKey", libthrift091.TFieldRequirementType.OPTIONAL, new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, AlertRuleKey.class))); tmpMap.put(_Fields.EMAILS, new libthrift091.meta_data.FieldMetaData("emails", libthrift091.TFieldRequirementType.OPTIONAL, new libthrift091.meta_data.ListMetaData(libthrift091.protocol.TType.LIST, new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)))); tmpMap.put(_Fields.PHONES, new libthrift091.meta_data.FieldMetaData("phones", libthrift091.TFieldRequirementType.OPTIONAL, new libthrift091.meta_data.ListMetaData(libthrift091.protocol.TType.LIST, new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(AlertRule.class, metaDataMap); } public AlertRule() { } /** * Performs a deep copy on <i>other</i>. */ public AlertRule(AlertRule other) { if (other.isSetRuleKey()) { this.ruleKey = new AlertRuleKey(other.ruleKey); } if (other.isSetEmails()) { List<String> __this__emails = new ArrayList<String>(other.emails); this.emails = __this__emails; } if (other.isSetPhones()) { List<String> __this__phones = new ArrayList<String>(other.phones); this.phones = __this__phones; } } public AlertRule deepCopy() { return new AlertRule(this); } @Override public void clear() { this.ruleKey = null; this.emails = null; this.phones = null; } public AlertRuleKey getRuleKey() { return this.ruleKey; } public AlertRule setRuleKey(AlertRuleKey ruleKey) { this.ruleKey = ruleKey; return this; } public void unsetRuleKey() { this.ruleKey = null; } /** Returns true if field ruleKey is set (has been assigned a value) and false otherwise */ public boolean isSetRuleKey() { return this.ruleKey != null; } public void setRuleKeyIsSet(boolean value) { if (!value) { this.ruleKey = null; } } public int getEmailsSize() { return (this.emails == null) ? 0 : this.emails.size(); } public java.util.Iterator<String> getEmailsIterator() { return (this.emails == null) ? null : this.emails.iterator(); } public void addToEmails(String elem) { if (this.emails == null) { this.emails = new ArrayList<String>(); } this.emails.add(elem); } public List<String> getEmails() { return this.emails; } public AlertRule setEmails(List<String> emails) { this.emails = emails; return this; } public void unsetEmails() { this.emails = null; } /** Returns true if field emails is set (has been assigned a value) and false otherwise */ public boolean isSetEmails() { return this.emails != null; } public void setEmailsIsSet(boolean value) { if (!value) { this.emails = null; } } public int getPhonesSize() { return (this.phones == null) ? 0 : this.phones.size(); } public java.util.Iterator<String> getPhonesIterator() { return (this.phones == null) ? null : this.phones.iterator(); } public void addToPhones(String elem) { if (this.phones == null) { this.phones = new ArrayList<String>(); } this.phones.add(elem); } public List<String> getPhones() { return this.phones; } public AlertRule setPhones(List<String> phones) { this.phones = phones; return this; } public void unsetPhones() { this.phones = null; } /** Returns true if field phones is set (has been assigned a value) and false otherwise */ public boolean isSetPhones() { return this.phones != null; } public void setPhonesIsSet(boolean value) { if (!value) { this.phones = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case RULE_KEY: if (value == null) { unsetRuleKey(); } else { setRuleKey((AlertRuleKey)value); } break; case EMAILS: if (value == null) { unsetEmails(); } else { setEmails((List<String>)value); } break; case PHONES: if (value == null) { unsetPhones(); } else { setPhones((List<String>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case RULE_KEY: return getRuleKey(); case EMAILS: return getEmails(); case PHONES: return getPhones(); } 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 RULE_KEY: return isSetRuleKey(); case EMAILS: return isSetEmails(); case PHONES: return isSetPhones(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof AlertRule) return this.equals((AlertRule)that); return false; } public boolean equals(AlertRule that) { if (that == null) return false; boolean this_present_ruleKey = true && this.isSetRuleKey(); boolean that_present_ruleKey = true && that.isSetRuleKey(); if (this_present_ruleKey || that_present_ruleKey) { if (!(this_present_ruleKey && that_present_ruleKey)) return false; if (!this.ruleKey.equals(that.ruleKey)) return false; } boolean this_present_emails = true && this.isSetEmails(); boolean that_present_emails = true && that.isSetEmails(); if (this_present_emails || that_present_emails) { if (!(this_present_emails && that_present_emails)) return false; if (!this.emails.equals(that.emails)) return false; } boolean this_present_phones = true && this.isSetPhones(); boolean that_present_phones = true && that.isSetPhones(); if (this_present_phones || that_present_phones) { if (!(this_present_phones && that_present_phones)) return false; if (!this.phones.equals(that.phones)) return false; } return true; } @Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_ruleKey = true && (isSetRuleKey()); list.add(present_ruleKey); if (present_ruleKey) list.add(ruleKey); boolean present_emails = true && (isSetEmails()); list.add(present_emails); if (present_emails) list.add(emails); boolean present_phones = true && (isSetPhones()); list.add(present_phones); if (present_phones) list.add(phones); return list.hashCode(); } @Override public int compareTo(AlertRule other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetRuleKey()).compareTo(other.isSetRuleKey()); if (lastComparison != 0) { return lastComparison; } if (isSetRuleKey()) { lastComparison = libthrift091.TBaseHelper.compareTo(this.ruleKey, other.ruleKey); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetEmails()).compareTo(other.isSetEmails()); if (lastComparison != 0) { return lastComparison; } if (isSetEmails()) { lastComparison = libthrift091.TBaseHelper.compareTo(this.emails, other.emails); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetPhones()).compareTo(other.isSetPhones()); if (lastComparison != 0) { return lastComparison; } if (isSetPhones()) { lastComparison = libthrift091.TBaseHelper.compareTo(this.phones, other.phones); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(libthrift091.protocol.TProtocol iprot) throws libthrift091.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("AlertRule("); boolean first = true; if (isSetRuleKey()) { sb.append("ruleKey:"); if (this.ruleKey == null) { sb.append("null"); } else { sb.append(this.ruleKey); } first = false; } if (isSetEmails()) { if (!first) sb.append(", "); sb.append("emails:"); if (this.emails == null) { sb.append("null"); } else { sb.append(this.emails); } first = false; } if (isSetPhones()) { if (!first) sb.append(", "); sb.append("phones:"); if (this.phones == null) { sb.append("null"); } else { sb.append(this.phones); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws libthrift091.TException { // check for required fields // check for sub-struct validity if (ruleKey != null) { ruleKey.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(out))); } catch (libthrift091.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(in))); } catch (libthrift091.TException te) { throw new java.io.IOException(te); } } private static class AlertRuleStandardSchemeFactory implements SchemeFactory { public AlertRuleStandardScheme getScheme() { return new AlertRuleStandardScheme(); } } private static class AlertRuleStandardScheme extends StandardScheme<AlertRule> { public void read(libthrift091.protocol.TProtocol iprot, AlertRule struct) throws libthrift091.TException { libthrift091.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == libthrift091.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // RULE_KEY if (schemeField.type == libthrift091.protocol.TType.STRUCT) { struct.ruleKey = new AlertRuleKey(); struct.ruleKey.read(iprot); struct.setRuleKeyIsSet(true); } else { libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // EMAILS if (schemeField.type == libthrift091.protocol.TType.LIST) { { libthrift091.protocol.TList _list0 = iprot.readListBegin(); struct.emails = new ArrayList<String>(_list0.size); String _elem1; for (int _i2 = 0; _i2 < _list0.size; ++_i2) { _elem1 = iprot.readString(); struct.emails.add(_elem1); } iprot.readListEnd(); } struct.setEmailsIsSet(true); } else { libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // PHONES if (schemeField.type == libthrift091.protocol.TType.LIST) { { libthrift091.protocol.TList _list3 = iprot.readListBegin(); struct.phones = new ArrayList<String>(_list3.size); String _elem4; for (int _i5 = 0; _i5 < _list3.size; ++_i5) { _elem4 = iprot.readString(); struct.phones.add(_elem4); } iprot.readListEnd(); } struct.setPhonesIsSet(true); } else { libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(libthrift091.protocol.TProtocol oprot, AlertRule struct) throws libthrift091.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.ruleKey != null) { if (struct.isSetRuleKey()) { oprot.writeFieldBegin(RULE_KEY_FIELD_DESC); struct.ruleKey.write(oprot); oprot.writeFieldEnd(); } } if (struct.emails != null) { if (struct.isSetEmails()) { oprot.writeFieldBegin(EMAILS_FIELD_DESC); { oprot.writeListBegin(new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, struct.emails.size())); for (String _iter6 : struct.emails) { oprot.writeString(_iter6); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } if (struct.phones != null) { if (struct.isSetPhones()) { oprot.writeFieldBegin(PHONES_FIELD_DESC); { oprot.writeListBegin(new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, struct.phones.size())); for (String _iter7 : struct.phones) { oprot.writeString(_iter7); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class AlertRuleTupleSchemeFactory implements SchemeFactory { public AlertRuleTupleScheme getScheme() { return new AlertRuleTupleScheme(); } } private static class AlertRuleTupleScheme extends TupleScheme<AlertRule> { @Override public void write(libthrift091.protocol.TProtocol prot, AlertRule struct) throws libthrift091.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetRuleKey()) { optionals.set(0); } if (struct.isSetEmails()) { optionals.set(1); } if (struct.isSetPhones()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetRuleKey()) { struct.ruleKey.write(oprot); } if (struct.isSetEmails()) { { oprot.writeI32(struct.emails.size()); for (String _iter8 : struct.emails) { oprot.writeString(_iter8); } } } if (struct.isSetPhones()) { { oprot.writeI32(struct.phones.size()); for (String _iter9 : struct.phones) { oprot.writeString(_iter9); } } } } @Override public void read(libthrift091.protocol.TProtocol prot, AlertRule struct) throws libthrift091.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.ruleKey = new AlertRuleKey(); struct.ruleKey.read(iprot); struct.setRuleKeyIsSet(true); } if (incoming.get(1)) { { libthrift091.protocol.TList _list10 = new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, iprot.readI32()); struct.emails = new ArrayList<String>(_list10.size); String _elem11; for (int _i12 = 0; _i12 < _list10.size; ++_i12) { _elem11 = iprot.readString(); struct.emails.add(_elem11); } } struct.setEmailsIsSet(true); } if (incoming.get(2)) { { libthrift091.protocol.TList _list13 = new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, iprot.readI32()); struct.phones = new ArrayList<String>(_list13.size); String _elem14; for (int _i15 = 0; _i15 < _list13.size; ++_i15) { _elem14 = iprot.readString(); struct.phones.add(_elem14); } } struct.setPhonesIsSet(true); } } } }