@Override
  public int getEncodeSize() {

    return BufferHelper.sizeOfNullableSimpleString(
            addressFullMessagePolicy != null ? addressFullMessagePolicy.toString() : null)
        + BufferHelper.sizeOfNullableLong(maxSizeBytes)
        + BufferHelper.sizeOfNullableLong(pageSizeBytes)
        + BufferHelper.sizeOfNullableInteger(pageMaxCache)
        + BufferHelper.sizeOfNullableBoolean(dropMessagesWhenFull)
        + BufferHelper.sizeOfNullableInteger(maxDeliveryAttempts)
        + BufferHelper.sizeOfNullableInteger(messageCounterHistoryDayLimit)
        + BufferHelper.sizeOfNullableLong(redeliveryDelay)
        + BufferHelper.sizeOfNullableDouble(redeliveryMultiplier)
        + BufferHelper.sizeOfNullableLong(maxRedeliveryDelay)
        + SimpleString.sizeofNullableString(deadLetterAddress)
        + SimpleString.sizeofNullableString(expiryAddress)
        + BufferHelper.sizeOfNullableLong(expiryDelay)
        + BufferHelper.sizeOfNullableBoolean(lastValueQueue)
        + BufferHelper.sizeOfNullableLong(redistributionDelay)
        + BufferHelper.sizeOfNullableBoolean(sendToDLAOnNoRoute)
        + BufferHelper.sizeOfNullableLong(slowConsumerCheckPeriod)
        + BufferHelper.sizeOfNullableLong(slowConsumerThreshold)
        + BufferHelper.sizeOfNullableSimpleString(
            slowConsumerPolicy != null ? slowConsumerPolicy.toString() : null)
        + BufferHelper.sizeOfNullableBoolean(autoCreateJmsQueues)
        + BufferHelper.sizeOfNullableBoolean(autoDeleteJmsQueues);
  }
  @Override
  public void decode(ActiveMQBuffer buffer) {
    SimpleString policyStr = buffer.readNullableSimpleString();

    if (policyStr != null) {
      addressFullMessagePolicy = AddressFullMessagePolicy.valueOf(policyStr.toString());
    } else {
      addressFullMessagePolicy = null;
    }

    maxSizeBytes = BufferHelper.readNullableLong(buffer);

    pageSizeBytes = BufferHelper.readNullableLong(buffer);

    pageMaxCache = BufferHelper.readNullableInteger(buffer);

    dropMessagesWhenFull = BufferHelper.readNullableBoolean(buffer);

    maxDeliveryAttempts = BufferHelper.readNullableInteger(buffer);

    messageCounterHistoryDayLimit = BufferHelper.readNullableInteger(buffer);

    redeliveryDelay = BufferHelper.readNullableLong(buffer);

    redeliveryMultiplier = BufferHelper.readNullableDouble(buffer);

    maxRedeliveryDelay = BufferHelper.readNullableLong(buffer);

    deadLetterAddress = buffer.readNullableSimpleString();

    expiryAddress = buffer.readNullableSimpleString();

    expiryDelay = BufferHelper.readNullableLong(buffer);

    lastValueQueue = BufferHelper.readNullableBoolean(buffer);

    redistributionDelay = BufferHelper.readNullableLong(buffer);

    sendToDLAOnNoRoute = BufferHelper.readNullableBoolean(buffer);

    slowConsumerThreshold = BufferHelper.readNullableLong(buffer);

    slowConsumerCheckPeriod = BufferHelper.readNullableLong(buffer);

    policyStr = buffer.readNullableSimpleString();

    if (policyStr != null) {
      slowConsumerPolicy = SlowConsumerPolicy.valueOf(policyStr.toString());
    } else {
      slowConsumerPolicy = null;
    }

    autoCreateJmsQueues = BufferHelper.readNullableBoolean(buffer);

    autoDeleteJmsQueues = BufferHelper.readNullableBoolean(buffer);
  }
  @Override
  public void encode(ActiveMQBuffer buffer) {
    buffer.writeNullableSimpleString(
        addressFullMessagePolicy != null
            ? new SimpleString(addressFullMessagePolicy.toString())
            : null);

    BufferHelper.writeNullableLong(buffer, maxSizeBytes);

    BufferHelper.writeNullableLong(buffer, pageSizeBytes);

    BufferHelper.writeNullableInteger(buffer, pageMaxCache);

    BufferHelper.writeNullableBoolean(buffer, dropMessagesWhenFull);

    BufferHelper.writeNullableInteger(buffer, maxDeliveryAttempts);

    BufferHelper.writeNullableInteger(buffer, messageCounterHistoryDayLimit);

    BufferHelper.writeNullableLong(buffer, redeliveryDelay);

    BufferHelper.writeNullableDouble(buffer, redeliveryMultiplier);

    BufferHelper.writeNullableLong(buffer, maxRedeliveryDelay);

    buffer.writeNullableSimpleString(deadLetterAddress);

    buffer.writeNullableSimpleString(expiryAddress);

    BufferHelper.writeNullableLong(buffer, expiryDelay);

    BufferHelper.writeNullableBoolean(buffer, lastValueQueue);

    BufferHelper.writeNullableLong(buffer, redistributionDelay);

    BufferHelper.writeNullableBoolean(buffer, sendToDLAOnNoRoute);

    BufferHelper.writeNullableLong(buffer, slowConsumerThreshold);

    BufferHelper.writeNullableLong(buffer, slowConsumerCheckPeriod);

    buffer.writeNullableSimpleString(
        slowConsumerPolicy != null ? new SimpleString(slowConsumerPolicy.toString()) : null);

    BufferHelper.writeNullableBoolean(buffer, autoCreateJmsQueues);

    BufferHelper.writeNullableBoolean(buffer, autoDeleteJmsQueues);
  }
 /* (non-Javadoc)
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result =
       prime * result
           + ((addressFullMessagePolicy == null) ? 0 : addressFullMessagePolicy.hashCode());
   result = prime * result + ((deadLetterAddress == null) ? 0 : deadLetterAddress.hashCode());
   result =
       prime * result + ((dropMessagesWhenFull == null) ? 0 : dropMessagesWhenFull.hashCode());
   result = prime * result + ((expiryAddress == null) ? 0 : expiryAddress.hashCode());
   result = prime * result + ((expiryDelay == null) ? 0 : expiryDelay.hashCode());
   result = prime * result + ((lastValueQueue == null) ? 0 : lastValueQueue.hashCode());
   result = prime * result + ((maxDeliveryAttempts == null) ? 0 : maxDeliveryAttempts.hashCode());
   result = prime * result + ((maxSizeBytes == null) ? 0 : maxSizeBytes.hashCode());
   result =
       prime * result
           + ((messageCounterHistoryDayLimit == null)
               ? 0
               : messageCounterHistoryDayLimit.hashCode());
   result = prime * result + ((pageSizeBytes == null) ? 0 : pageSizeBytes.hashCode());
   result = prime * result + ((pageMaxCache == null) ? 0 : pageMaxCache.hashCode());
   result = prime * result + ((redeliveryDelay == null) ? 0 : redeliveryDelay.hashCode());
   result =
       prime * result + ((redeliveryMultiplier == null) ? 0 : redeliveryMultiplier.hashCode());
   result = prime * result + ((maxRedeliveryDelay == null) ? 0 : maxRedeliveryDelay.hashCode());
   result = prime * result + ((redistributionDelay == null) ? 0 : redistributionDelay.hashCode());
   result = prime * result + ((sendToDLAOnNoRoute == null) ? 0 : sendToDLAOnNoRoute.hashCode());
   result =
       prime * result + ((slowConsumerThreshold == null) ? 0 : slowConsumerThreshold.hashCode());
   result =
       prime * result
           + ((slowConsumerCheckPeriod == null) ? 0 : slowConsumerCheckPeriod.hashCode());
   result = prime * result + ((slowConsumerPolicy == null) ? 0 : slowConsumerPolicy.hashCode());
   result = prime * result + ((autoCreateJmsQueues == null) ? 0 : autoCreateJmsQueues.hashCode());
   result = prime * result + ((autoDeleteJmsQueues == null) ? 0 : autoDeleteJmsQueues.hashCode());
   return result;
 }
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   AddressSettings other = (AddressSettings) obj;
   if (addressFullMessagePolicy == null) {
     if (other.addressFullMessagePolicy != null) return false;
   } else if (!addressFullMessagePolicy.equals(other.addressFullMessagePolicy)) return false;
   if (deadLetterAddress == null) {
     if (other.deadLetterAddress != null) return false;
   } else if (!deadLetterAddress.equals(other.deadLetterAddress)) return false;
   if (dropMessagesWhenFull == null) {
     if (other.dropMessagesWhenFull != null) return false;
   } else if (!dropMessagesWhenFull.equals(other.dropMessagesWhenFull)) return false;
   if (expiryAddress == null) {
     if (other.expiryAddress != null) return false;
   } else if (!expiryAddress.equals(other.expiryAddress)) return false;
   if (expiryDelay == null) {
     if (other.expiryDelay != null) return false;
   } else if (!expiryDelay.equals(other.expiryDelay)) return false;
   if (lastValueQueue == null) {
     if (other.lastValueQueue != null) return false;
   } else if (!lastValueQueue.equals(other.lastValueQueue)) return false;
   if (maxDeliveryAttempts == null) {
     if (other.maxDeliveryAttempts != null) return false;
   } else if (!maxDeliveryAttempts.equals(other.maxDeliveryAttempts)) return false;
   if (maxSizeBytes == null) {
     if (other.maxSizeBytes != null) return false;
   } else if (!maxSizeBytes.equals(other.maxSizeBytes)) return false;
   if (messageCounterHistoryDayLimit == null) {
     if (other.messageCounterHistoryDayLimit != null) return false;
   } else if (!messageCounterHistoryDayLimit.equals(other.messageCounterHistoryDayLimit))
     return false;
   if (pageSizeBytes == null) {
     if (other.pageSizeBytes != null) return false;
   } else if (!pageSizeBytes.equals(other.pageSizeBytes)) return false;
   if (pageMaxCache == null) {
     if (other.pageMaxCache != null) return false;
   } else if (!pageMaxCache.equals(other.pageMaxCache)) return false;
   if (redeliveryDelay == null) {
     if (other.redeliveryDelay != null) return false;
   } else if (!redeliveryDelay.equals(other.redeliveryDelay)) return false;
   if (redeliveryMultiplier == null) {
     if (other.redeliveryMultiplier != null) return false;
   } else if (!redeliveryMultiplier.equals(other.redeliveryMultiplier)) return false;
   if (maxRedeliveryDelay == null) {
     if (other.maxRedeliveryDelay != null) return false;
   } else if (!maxRedeliveryDelay.equals(other.maxRedeliveryDelay)) return false;
   if (redistributionDelay == null) {
     if (other.redistributionDelay != null) return false;
   } else if (!redistributionDelay.equals(other.redistributionDelay)) return false;
   if (sendToDLAOnNoRoute == null) {
     if (other.sendToDLAOnNoRoute != null) return false;
   } else if (!sendToDLAOnNoRoute.equals(other.sendToDLAOnNoRoute)) return false;
   if (slowConsumerThreshold == null) {
     if (other.slowConsumerThreshold != null) return false;
   } else if (!slowConsumerThreshold.equals(other.slowConsumerThreshold)) return false;
   if (slowConsumerCheckPeriod == null) {
     if (other.slowConsumerCheckPeriod != null) return false;
   } else if (!slowConsumerCheckPeriod.equals(other.slowConsumerCheckPeriod)) return false;
   if (slowConsumerPolicy == null) {
     if (other.slowConsumerPolicy != null) return false;
   } else if (!slowConsumerPolicy.equals(other.slowConsumerPolicy)) return false;
   if (autoCreateJmsQueues == null) {
     if (other.autoCreateJmsQueues != null) return false;
   } else if (!autoCreateJmsQueues.equals(other.autoCreateJmsQueues)) return false;
   if (autoDeleteJmsQueues == null) {
     if (other.autoDeleteJmsQueues != null) return false;
   } else if (!autoDeleteJmsQueues.equals(other.autoDeleteJmsQueues)) return false;
   return true;
 }