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

com.twitter.distributedlog.thrift.AccessControlEntry Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package com.twitter.distributedlog.thrift;

import org.apache.commons.lang.builder.HashCodeBuilder;
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.*;

// No additional import required for struct/union.

public class AccessControlEntry implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("AccessControlEntry");

  private static final TField DENY_WRITE_FIELD_DESC = new TField("denyWrite", TType.BOOL, (short)1);
  private static final TField DENY_TRUNCATE_FIELD_DESC = new TField("denyTruncate", TType.BOOL, (short)2);
  private static final TField DENY_DELETE_FIELD_DESC = new TField("denyDelete", TType.BOOL, (short)3);
  private static final TField DENY_ACQUIRE_FIELD_DESC = new TField("denyAcquire", TType.BOOL, (short)4);
  private static final TField DENY_RELEASE_FIELD_DESC = new TField("denyRelease", TType.BOOL, (short)5);


  public boolean denyWrite;
  public boolean denyTruncate;
  public boolean denyDelete;
  public boolean denyAcquire;
  public boolean denyRelease;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    DENY_WRITE((short)1, "denyWrite"),
    DENY_TRUNCATE((short)2, "denyTruncate"),
    DENY_DELETE((short)3, "denyDelete"),
    DENY_ACQUIRE((short)4, "denyAcquire"),
    DENY_RELEASE((short)5, "denyRelease");
  
    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: // DENY_WRITE
  	return DENY_WRITE;
        case 2: // DENY_TRUNCATE
  	return DENY_TRUNCATE;
        case 3: // DENY_DELETE
  	return DENY_DELETE;
        case 4: // DENY_ACQUIRE
  	return DENY_ACQUIRE;
        case 5: // DENY_RELEASE
  	return DENY_RELEASE;
        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 __DENYWRITE_ISSET_ID = 0;
  private static final int __DENYTRUNCATE_ISSET_ID = 1;
  private static final int __DENYDELETE_ISSET_ID = 2;
  private static final int __DENYACQUIRE_ISSET_ID = 3;
  private static final int __DENYRELEASE_ISSET_ID = 4;
  private BitSet __isset_bit_vector = new BitSet(5);

  public static final Map<_Fields, FieldMetaData> metaDataMap;
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.DENY_WRITE, new FieldMetaData("denyWrite", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BOOL)));
    tmpMap.put(_Fields.DENY_TRUNCATE, new FieldMetaData("denyTruncate", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BOOL)));
    tmpMap.put(_Fields.DENY_DELETE, new FieldMetaData("denyDelete", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BOOL)));
    tmpMap.put(_Fields.DENY_ACQUIRE, new FieldMetaData("denyAcquire", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BOOL)));
    tmpMap.put(_Fields.DENY_RELEASE, new FieldMetaData("denyRelease", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BOOL)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(AccessControlEntry.class, metaDataMap);
  }


  public AccessControlEntry() {
  }


  /**
   * Performs a deep copy on other.
   */
  public AccessControlEntry(AccessControlEntry other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.denyWrite = other.denyWrite;
    this.denyTruncate = other.denyTruncate;
    this.denyDelete = other.denyDelete;
    this.denyAcquire = other.denyAcquire;
    this.denyRelease = other.denyRelease;
  }

  public AccessControlEntry deepCopy() {
    return new AccessControlEntry(this);
  }

  @Override
  public void clear() {
    setDenyWriteIsSet(false);
    this.denyWrite = false;
    setDenyTruncateIsSet(false);
    this.denyTruncate = false;
    setDenyDeleteIsSet(false);
    this.denyDelete = false;
    setDenyAcquireIsSet(false);
    this.denyAcquire = false;
    setDenyReleaseIsSet(false);
    this.denyRelease = false;
  }

  public boolean isDenyWrite() {
    return this.denyWrite;
  }

  public AccessControlEntry setDenyWrite(boolean denyWrite) {
    this.denyWrite = denyWrite;
    setDenyWriteIsSet(true);

    return this;
  }

  public void unsetDenyWrite() {
  __isset_bit_vector.clear(__DENYWRITE_ISSET_ID);
  }

  /** Returns true if field denyWrite is set (has been asigned a value) and false otherwise */
  public boolean isSetDenyWrite() {
    return __isset_bit_vector.get(__DENYWRITE_ISSET_ID);
  }

  public void setDenyWriteIsSet(boolean value) {
    __isset_bit_vector.set(__DENYWRITE_ISSET_ID, value);
  }

  public boolean isDenyTruncate() {
    return this.denyTruncate;
  }

  public AccessControlEntry setDenyTruncate(boolean denyTruncate) {
    this.denyTruncate = denyTruncate;
    setDenyTruncateIsSet(true);

    return this;
  }

  public void unsetDenyTruncate() {
  __isset_bit_vector.clear(__DENYTRUNCATE_ISSET_ID);
  }

  /** Returns true if field denyTruncate is set (has been asigned a value) and false otherwise */
  public boolean isSetDenyTruncate() {
    return __isset_bit_vector.get(__DENYTRUNCATE_ISSET_ID);
  }

  public void setDenyTruncateIsSet(boolean value) {
    __isset_bit_vector.set(__DENYTRUNCATE_ISSET_ID, value);
  }

  public boolean isDenyDelete() {
    return this.denyDelete;
  }

  public AccessControlEntry setDenyDelete(boolean denyDelete) {
    this.denyDelete = denyDelete;
    setDenyDeleteIsSet(true);

    return this;
  }

  public void unsetDenyDelete() {
  __isset_bit_vector.clear(__DENYDELETE_ISSET_ID);
  }

  /** Returns true if field denyDelete is set (has been asigned a value) and false otherwise */
  public boolean isSetDenyDelete() {
    return __isset_bit_vector.get(__DENYDELETE_ISSET_ID);
  }

  public void setDenyDeleteIsSet(boolean value) {
    __isset_bit_vector.set(__DENYDELETE_ISSET_ID, value);
  }

  public boolean isDenyAcquire() {
    return this.denyAcquire;
  }

  public AccessControlEntry setDenyAcquire(boolean denyAcquire) {
    this.denyAcquire = denyAcquire;
    setDenyAcquireIsSet(true);

    return this;
  }

  public void unsetDenyAcquire() {
  __isset_bit_vector.clear(__DENYACQUIRE_ISSET_ID);
  }

  /** Returns true if field denyAcquire is set (has been asigned a value) and false otherwise */
  public boolean isSetDenyAcquire() {
    return __isset_bit_vector.get(__DENYACQUIRE_ISSET_ID);
  }

  public void setDenyAcquireIsSet(boolean value) {
    __isset_bit_vector.set(__DENYACQUIRE_ISSET_ID, value);
  }

  public boolean isDenyRelease() {
    return this.denyRelease;
  }

  public AccessControlEntry setDenyRelease(boolean denyRelease) {
    this.denyRelease = denyRelease;
    setDenyReleaseIsSet(true);

    return this;
  }

  public void unsetDenyRelease() {
  __isset_bit_vector.clear(__DENYRELEASE_ISSET_ID);
  }

  /** Returns true if field denyRelease is set (has been asigned a value) and false otherwise */
  public boolean isSetDenyRelease() {
    return __isset_bit_vector.get(__DENYRELEASE_ISSET_ID);
  }

  public void setDenyReleaseIsSet(boolean value) {
    __isset_bit_vector.set(__DENYRELEASE_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case DENY_WRITE:
      if (value == null) {
        unsetDenyWrite();
      } else {
        setDenyWrite((Boolean)value);
      }
      break;
    case DENY_TRUNCATE:
      if (value == null) {
        unsetDenyTruncate();
      } else {
        setDenyTruncate((Boolean)value);
      }
      break;
    case DENY_DELETE:
      if (value == null) {
        unsetDenyDelete();
      } else {
        setDenyDelete((Boolean)value);
      }
      break;
    case DENY_ACQUIRE:
      if (value == null) {
        unsetDenyAcquire();
      } else {
        setDenyAcquire((Boolean)value);
      }
      break;
    case DENY_RELEASE:
      if (value == null) {
        unsetDenyRelease();
      } else {
        setDenyRelease((Boolean)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case DENY_WRITE:
      return new Boolean(isDenyWrite());
    case DENY_TRUNCATE:
      return new Boolean(isDenyTruncate());
    case DENY_DELETE:
      return new Boolean(isDenyDelete());
    case DENY_ACQUIRE:
      return new Boolean(isDenyAcquire());
    case DENY_RELEASE:
      return new Boolean(isDenyRelease());
    }
    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 DENY_WRITE:
      return isSetDenyWrite();
    case DENY_TRUNCATE:
      return isSetDenyTruncate();
    case DENY_DELETE:
      return isSetDenyDelete();
    case DENY_ACQUIRE:
      return isSetDenyAcquire();
    case DENY_RELEASE:
      return isSetDenyRelease();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof AccessControlEntry)
      return this.equals((AccessControlEntry)that);
    return false;
  }

  public boolean equals(AccessControlEntry that) {
    if (that == null)
      return false;
    boolean this_present_denyWrite = true && this.isSetDenyWrite();
    boolean that_present_denyWrite = true && that.isSetDenyWrite();
    if (this_present_denyWrite || that_present_denyWrite) {
      if (!(this_present_denyWrite && that_present_denyWrite))
        return false;
      if (this.denyWrite != that.denyWrite)
        return false;
    }
    boolean this_present_denyTruncate = true && this.isSetDenyTruncate();
    boolean that_present_denyTruncate = true && that.isSetDenyTruncate();
    if (this_present_denyTruncate || that_present_denyTruncate) {
      if (!(this_present_denyTruncate && that_present_denyTruncate))
        return false;
      if (this.denyTruncate != that.denyTruncate)
        return false;
    }
    boolean this_present_denyDelete = true && this.isSetDenyDelete();
    boolean that_present_denyDelete = true && that.isSetDenyDelete();
    if (this_present_denyDelete || that_present_denyDelete) {
      if (!(this_present_denyDelete && that_present_denyDelete))
        return false;
      if (this.denyDelete != that.denyDelete)
        return false;
    }
    boolean this_present_denyAcquire = true && this.isSetDenyAcquire();
    boolean that_present_denyAcquire = true && that.isSetDenyAcquire();
    if (this_present_denyAcquire || that_present_denyAcquire) {
      if (!(this_present_denyAcquire && that_present_denyAcquire))
        return false;
      if (this.denyAcquire != that.denyAcquire)
        return false;
    }
    boolean this_present_denyRelease = true && this.isSetDenyRelease();
    boolean that_present_denyRelease = true && that.isSetDenyRelease();
    if (this_present_denyRelease || that_present_denyRelease) {
      if (!(this_present_denyRelease && that_present_denyRelease))
        return false;
      if (this.denyRelease != that.denyRelease)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();
    boolean present_denyWrite = true && (isSetDenyWrite());
    builder.append(present_denyWrite);
    if (present_denyWrite)
      builder.append(denyWrite);
    boolean present_denyTruncate = true && (isSetDenyTruncate());
    builder.append(present_denyTruncate);
    if (present_denyTruncate)
      builder.append(denyTruncate);
    boolean present_denyDelete = true && (isSetDenyDelete());
    builder.append(present_denyDelete);
    if (present_denyDelete)
      builder.append(denyDelete);
    boolean present_denyAcquire = true && (isSetDenyAcquire());
    builder.append(present_denyAcquire);
    if (present_denyAcquire)
      builder.append(denyAcquire);
    boolean present_denyRelease = true && (isSetDenyRelease());
    builder.append(present_denyRelease);
    if (present_denyRelease)
      builder.append(denyRelease);
    return builder.toHashCode();
  }

  public int compareTo(AccessControlEntry other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    AccessControlEntry typedOther = (AccessControlEntry)other;

    lastComparison = Boolean.valueOf(isSetDenyWrite()).compareTo(typedOther.isSetDenyWrite());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDenyWrite()) {
      lastComparison = TBaseHelper.compareTo(this.denyWrite, typedOther.denyWrite);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDenyTruncate()).compareTo(typedOther.isSetDenyTruncate());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDenyTruncate()) {
      lastComparison = TBaseHelper.compareTo(this.denyTruncate, typedOther.denyTruncate);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDenyDelete()).compareTo(typedOther.isSetDenyDelete());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDenyDelete()) {
      lastComparison = TBaseHelper.compareTo(this.denyDelete, typedOther.denyDelete);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDenyAcquire()).compareTo(typedOther.isSetDenyAcquire());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDenyAcquire()) {
      lastComparison = TBaseHelper.compareTo(this.denyAcquire, typedOther.denyAcquire);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDenyRelease()).compareTo(typedOther.isSetDenyRelease());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDenyRelease()) {
      lastComparison = TBaseHelper.compareTo(this.denyRelease, typedOther.denyRelease);
      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: // DENY_WRITE
          if (field.type == TType.BOOL) {
            this.denyWrite = iprot.readBool();
            setDenyWriteIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // DENY_TRUNCATE
          if (field.type == TType.BOOL) {
            this.denyTruncate = iprot.readBool();
            setDenyTruncateIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // DENY_DELETE
          if (field.type == TType.BOOL) {
            this.denyDelete = iprot.readBool();
            setDenyDeleteIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // DENY_ACQUIRE
          if (field.type == TType.BOOL) {
            this.denyAcquire = iprot.readBool();
            setDenyAcquireIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // DENY_RELEASE
          if (field.type == TType.BOOL) {
            this.denyRelease = iprot.readBool();
            setDenyReleaseIsSet(true);
          } 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 (isSetDenyWrite()) {
      oprot.writeFieldBegin(DENY_WRITE_FIELD_DESC);
      oprot.writeBool(this.denyWrite);
      oprot.writeFieldEnd();
    }
    if (isSetDenyTruncate()) {
      oprot.writeFieldBegin(DENY_TRUNCATE_FIELD_DESC);
      oprot.writeBool(this.denyTruncate);
      oprot.writeFieldEnd();
    }
    if (isSetDenyDelete()) {
      oprot.writeFieldBegin(DENY_DELETE_FIELD_DESC);
      oprot.writeBool(this.denyDelete);
      oprot.writeFieldEnd();
    }
    if (isSetDenyAcquire()) {
      oprot.writeFieldBegin(DENY_ACQUIRE_FIELD_DESC);
      oprot.writeBool(this.denyAcquire);
      oprot.writeFieldEnd();
    }
    if (isSetDenyRelease()) {
      oprot.writeFieldBegin(DENY_RELEASE_FIELD_DESC);
      oprot.writeBool(this.denyRelease);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("AccessControlEntry(");
    boolean first = true;
    if (isSetDenyWrite()) {
      sb.append("denyWrite:");
      sb.append(this.denyWrite);
      first = false;
      }
    if (isSetDenyTruncate()) {
      if (!first) sb.append(", ");
      sb.append("denyTruncate:");
      sb.append(this.denyTruncate);
      first = false;
      }
    if (isSetDenyDelete()) {
      if (!first) sb.append(", ");
      sb.append("denyDelete:");
      sb.append(this.denyDelete);
      first = false;
      }
    if (isSetDenyAcquire()) {
      if (!first) sb.append(", ");
      sb.append("denyAcquire:");
      sb.append(this.denyAcquire);
      first = false;
      }
    if (isSetDenyRelease()) {
      if (!first) sb.append(", ");
      sb.append("denyRelease:");
      sb.append(this.denyRelease);
      first = false;
      }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy