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

com.microsoft.windowsazure.services.servicebus.models.QueueInfo Maven / Gradle / Ivy

The newest version!
/**
 * Copyright Microsoft Corporation
 * 
 * Licensed 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.
 */
package com.microsoft.windowsazure.services.servicebus.models;

import java.net.URI;
import java.util.Calendar;

import javax.ws.rs.core.MediaType;
import javax.xml.datatype.Duration;

import com.microsoft.windowsazure.services.servicebus.implementation.Content;
import com.microsoft.windowsazure.services.servicebus.implementation.EntityAvailabilityStatus;
import com.microsoft.windowsazure.services.servicebus.implementation.EntityStatus;
import com.microsoft.windowsazure.services.servicebus.implementation.Entry;
import com.microsoft.windowsazure.services.servicebus.implementation.EntryModel;
import com.microsoft.windowsazure.services.servicebus.implementation.MessageCountDetails;
import com.microsoft.windowsazure.services.servicebus.implementation.PartitioningPolicy;
import com.microsoft.windowsazure.services.servicebus.implementation.QueueDescription;

/**
 * Represents a queue.
 */
public class QueueInfo extends EntryModel {

    /**
     * Creates an instance of the QueueInfo class.
     */
    public QueueInfo() {
        super(new Entry(), new QueueDescription());
        getEntry().setContent(new Content());
        getEntry().getContent().setType(MediaType.APPLICATION_XML);
        getEntry().getContent().setQueueDescription(getModel());
    }

    /**
     * Creates an instance of the QueueInfo class using the
     * specified entry.
     * 
     * @param entry
     *            An Entry object.
     */
    public QueueInfo(Entry entry) {
        super(entry, entry.getContent().getQueueDescription());
    }

    /**
     * Creates an instance of the QueueInfo class using the
     * specified name.
     * 
     * @param path
     *            A String object that represents the name of the
     *            queue.
     */
    public QueueInfo(String path) {
        this();
        setPath(path);
    }

    /**
     * Returns the name of the queue.
     * 
     * @return A String object that represents the name of the
     *         queue.
     */
    public String getPath() {
        return getEntry().getTitle();
    }

    /**
     * Sets the name of the queue.
     * 
     * @param value
     *            A String that represents the name of the queue.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setPath(String value) {
        getEntry().setTitle(value);
        return this;
    }

    /**
     * Returns the duration of the lock.
     * 
     * @return A Duration object that represents the duration of
     *         the lock.
     */
    public Duration getLockDuration() {
        return getModel().getLockDuration();
    }

    /**
     * Sets the duration of the lock.
     * 
     * @param value
     *            The duration, in seconds, of the lock.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setLockDuration(Duration value) {
        getModel().setLockDuration(value);
        return this;
    }

    /**
     * Returns the maximum size of the queue.
     * 
     * @return The maximum size, in megabytes, of the queue.
     */
    public Long getMaxSizeInMegabytes() {
        return getModel().getMaxSizeInMegabytes();
    }

    /**
     * Sets the maximum size of the queue.
     * 
     * @param value
     *            The maximum size, in megabytes, of the queue.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setMaxSizeInMegabytes(Long value) {
        getModel().setMaxSizeInMegabytes(value);
        return this;
    }

    /**
     * Indicates whether duplicate message detection is required.
     * 
     * @return true if duplicate message detection is required;
     *         otherwise, false.
     */
    public Boolean isRequiresDuplicateDetection() {
        return getModel().isRequiresDuplicateDetection();
    }

    /**
     * Specifies whether duplicate message detection is required.
     * 
     * @param value
     *            true if duplicate message detection is required;
     *            otherwise, false.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setRequiresDuplicateDetection(Boolean value) {
        getModel().setRequiresDuplicateDetection(value);
        return this;
    }

    /**
     * Indicates whether the queue is session-aware.
     * 
     * @return true if the queue is session aware; otherwise,
     *         false.
     */
    public Boolean isRequiresSession() {
        return getModel().isRequiresSession();
    }

    /**
     * Specifies whether the queue is session-aware.
     * 
     * @param value
     *            true if the queue is session aware; otherwise,
     *            false.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setRequiresSession(Boolean value) {
        getModel().setRequiresSession(value);
        return this;
    }

    /**
     * Returns the default message time-to-live (TTL). This applies when dead
     * lettering is in effect.
     * 
     * @return A Duration object that represents the default
     *         message TTL.
     */
    public Duration getDefaultMessageTimeToLive() {
        return getModel().getDefaultMessageTimeToLive();
    }

    /**
     * Sets the default message time-to-live (TTL). This applies when dead
     * lettering is in effect.
     * 
     * @param value
     *            A Duration object that represents the default
     *            message TTL.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setDefaultMessageTimeToLive(Duration value) {
        getModel().setDefaultMessageTimeToLive(value);
        return this;
    }

    /**
     * Gets the time span before auto deletion starts.
     * 
     * @return A Duration object that represents the time span
     *         before auto deletion.
     */
    public Duration getAutoDeleteOnIdle() {
        return getModel().getAutoDeleteOnIdle();
    }

    /**
     * Sets the time span before auto deletion starts.
     * 
     * @param autoDeleteOnIdle
     *            A Duration object that represents the time span
     *            before auto deletion starts.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
        getModel().setAutoDeleteOnIdle(autoDeleteOnIdle);
        return this;
    }

    /**
     * Indicates whether dead lettering is in effect upon message expiration.
     * 
     * @return true if dead lettering is in effect; otherwise,
     *         false.
     */
    public Boolean isDeadLetteringOnMessageExpiration() {
        return getModel().isDeadLetteringOnMessageExpiration();
    }

    /**
     * Specifies whether dead lettering is in effect upon message expiration.
     * 
     * @param value
     *            true if dead lettering is in effect; otherwise,
     *            false.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setDeadLetteringOnMessageExpiration(Boolean value) {
        getModel().setDeadLetteringOnMessageExpiration(value);
        return this;
    }

    /**
     * Returns the time span during which the service bus will detect message
     * duplication. This applies when duplicate message detection is in effect.
     * 
     * @return A Duration object that represents the time span for
     *         detecting message duplication.
     */
    public Duration getDuplicateDetectionHistoryTimeWindow() {
        return getModel().getDuplicateDetectionHistoryTimeWindow();
    }

    /**
     * Sets the time span during which the service bus will detect message
     * duplication. This applies when duplicate message detection is in effect.
     * 
     * @param value
     *            A Duration object that represents the time span
     *            for detecting message duplication.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setDuplicateDetectionHistoryTimeWindow(Duration value) {
        getModel().setDuplicateDetectionHistoryTimeWindow(value);
        return this;
    }

    /**
     * Returns the maximum delivery count for the queue.
     * 
     * @return An Integer object that represents the maximum
     *         delivery count.
     */
    public Integer getMaxDeliveryCount() {
        return getModel().getMaxDeliveryCount();
    }

    /**
     * Sets the maximum delivery count for the queue.
     * 
     * @param value
     *            The maximum delivery count for the queue.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setMaxDeliveryCount(Integer value) {
        getModel().setMaxDeliveryCount(value);
        return this;
    }

    /**
     * Indicates whether batch operations are enabled.
     * 
     * @return true if batch operations are enabled; otherwise,
     *         false.
     */
    public Boolean isEnableBatchedOperations() {
        return getModel().isEnableBatchedOperations();
    }

    /**
     * Specifies whether batch operations are enabled.
     * 
     * @param value
     *            true if batch operations are enabled; otherwise,
     *            false.
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setEnableBatchedOperations(Boolean value) {
        getModel().setEnableBatchedOperations(value);
        return this;
    }

    /**
     * Returns the size of the queue.
     * 
     * @return A Long object that represents the size of the queue
     *         in bytes.
     */
    public Long getSizeInBytes() {
        return getModel().getSizeInBytes();
    }

    /**
     * Sets the size in bytes.
     * 
     * @param sizeInBytes
     *            the size in bytes
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setSizeInBytes(Long sizeInBytes) {
        getModel().setSizeInBytes(sizeInBytes);
        return this;
    }

    /**
     * Returns the number of messages in the queue.
     * 
     * @return A Long object that represents the number of messages
     *         in the queue.
     */
    public Long getMessageCount() {
        return getModel().getMessageCount();
    }

    /**
     * Sets the message count.
     * 
     * @param messageCount
     *            the message count
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setMessageCount(Long messageCount) {
        getModel().setMessageCount(messageCount);
        return this;
    }

    /**
     * Checks if is anonymous accessible.
     * 
     * @return true if the queue can be accessed anonymously.
     *         Otherwise, false.
     */
    public Boolean isAnonymousAccessible() {
        return getModel().isIsAnonymousAccessible();
    }

    /**
     * Sets the is anonymous accessible.
     * 
     * @param isAnonymousAccessible
     *            the is anonymous accessible
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setIsAnonymousAccessible(Boolean isAnonymousAccessible) {
        getModel().setIsAnonymousAccessible(isAnonymousAccessible);
        return this;
    }

    /**
     * Checks if is support ordering.
     * 
     * @return true if ordering is supported, otherwise,
     *         false.
     */
    public Boolean isSupportOrdering() {
        return getModel().isSupportOrdering();
    }

    /**
     * Sets the support ordering.
     * 
     * @param supportOrdering
     *            A Boolean object represents whether the queue
     *            supports ordering.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setSupportOrdering(Boolean supportOrdering) {
        getModel().setSupportOrdering(supportOrdering);
        return this;
    }

    /**
     * Gets the status.
     * 
     * @return A EntityStatus object.
     */
    public EntityStatus getStatus() {
        return getModel().getStatus();
    }

    /**
     * Sets the status.
     * 
     * @param entityStatus
     *            the entity status
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setStatus(EntityStatus entityStatus) {
        getModel().setStatus(entityStatus);
        return this;
    }

    /**
     * Gets the entity availability status.
     * 
     * @return A EntityAvailabilityStatus object which represents
     *         the availability status of the entity.
     */
    public EntityAvailabilityStatus getEntityAvailabilityStatus() {
        return getModel().getEntityAvailabilityStatus();
    }

    /**
     * Sets the entity availability status.
     * 
     * @param entityAvailabilityStatus
     *            A EntityAvailabilityStatus object.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setEntityAvailabilityStatus(
            EntityAvailabilityStatus entityAvailabilityStatus) {
        getModel().setEntityAvailabilityStatus(entityAvailabilityStatus);
        return this;
    }

    /**
     * Gets the created at.
     * 
     * @return A Calendar object which represents the time of the
     *         queue created at.
     */
    public Calendar getCreatedAt() {
        return getModel().getCreatedAt();
    }

    /**
     * Sets the created at.
     * 
     * @param createdAt
     *            A Calendar ojbect which represnets the time of
     *            the queue created at.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setCreatedAt(Calendar createdAt) {
        getModel().setCreatedAt(createdAt);
        return this;
    }

    /**
     * Gets the updated at.
     * 
     * @return A Calendar object which represents the time that the
     *         queue was updated at.
     */
    public Calendar getUpdatedAt() {
        return getModel().getUpdatedAt();
    }

    /**
     * Sets the updated at.
     * 
     * @param updatedAt
     *            A Calendar object which represents the time that
     *            the queue was updated at.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setUpdatedAt(Calendar updatedAt) {
        getModel().setUpdatedAt(updatedAt);
        return this;
    }

    /**
     * Gets the accessed at.
     * 
     * @return A Calendar object which represents the time that the
     *         queue was accessed at.
     */
    public Calendar getAccessedAt() {
        return getModel().getAccessedAt();
    }

    /**
     * Sets the accessed at.
     * 
     * @param accessedAt
     *            A Calendar object which represents the time that
     *            the queue was accessed at.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setAccessedAt(Calendar accessedAt) {
        getModel().setAccessedAt(accessedAt);
        return this;
    }

    /**
     * Gets the partitioning policy.
     * 
     * @return A PartitioningPolicy represents the partitioning
     *         policy.
     */
    public PartitioningPolicy getPartitioningPolicy() {
        return getModel().getPartitioningPolicy();
    }

    /**
     * Sets the partitioning policy.
     * 
     * @param partitioningPolicy
     *            A PartitioningPolicy represents the partitioning
     *            policy.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setPartitioningPolicy(PartitioningPolicy partitioningPolicy) {
        getModel().setPartitioningPolicy(partitioningPolicy);
        return this;
    }

    /**
     * Gets the user metadata.
     * 
     * @return A String objects which contains the user metadata.
     */
    public String getUserMetadata() {
        return getModel().getUserMetadata();
    }

    /**
     * Sets the user metadata.
     * 
     * @param userMetadata
     *            A String objects which contains the user
     *            metadata.
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setUserMetadata(String userMetadata) {
        getModel().setUserMetadata(userMetadata);
        return this;
    }

    /**
     * Gets the message count details.
     * 
     * @return A MessageCountDetails instance that represents the
     *         details of the message count.
     */
    public MessageCountDetails getCountDetails() {
        return getModel().getCountDetails();
    }

    /**
     * Sets the URI of the QueueInfo instance.
     * 
     * @param uri
     *            the URI of the QueueInfo
     * 
     * @return A QueueInfo object that represents the updated
     *         queue.
     */
    public QueueInfo setUri(URI uri) {
        getEntry().setId(uri.toString());
        return this;
    }

    /**
     * Gets the URI of the QueueInfo instance.
     * 
     * @return A URI representing the QueueInfo.
     */
    public URI getUri() {
        return URI.create(removeQueryString(getEntry().getId()));
    }

    /**
     * Removes the query string of the URI.
     * 
     * @param uri
     *            A raw string representing the URI of queue.
     * @return the string
     */
    private String removeQueryString(String uri) {
        String[] result = uri.split("\\?");
        return result[0];
    }

    /**
     * Sets the URI of the entity to forward to.
     * 
     * @param forwardTo
     *            A String instance representing the URI of the
     *            entity to forward message to.
     * @return A QueueInfo instance representing the updated queue
     *         information.
     */
    public QueueInfo setForwardTo(String forwardTo) {
        getModel().setForwardTo(forwardTo);
        return this;
    }

    /**
     * Gets a String instance representing entity to forward to.
     * 
     * @return A String instance representing the URI of the
     *         instance to forward to.
     */
    public String getForwardTo() {
        return getModel().getForwardTo();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy