001    /*
002     * Copyright 2014-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk.unboundidds.extensions;
022    
023    
024    
025    import java.io.Serializable;
026    import java.util.ArrayList;
027    import java.util.Collection;
028    import java.util.Collections;
029    import java.util.List;
030    
031    import com.unboundid.asn1.ASN1OctetString;
032    import com.unboundid.util.NotMutable;
033    import com.unboundid.util.ThreadSafety;
034    import com.unboundid.util.ThreadSafetyLevel;
035    import com.unboundid.util.Validator;
036    
037    
038    
039    /**
040     * <BLOCKQUOTE>
041     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
042     *   LDAP SDK for Java.  It is not available for use in applications that
043     *   include only the Standard Edition of the LDAP SDK, and is not supported for
044     *   use in conjunction with non-UnboundID products.
045     * </BLOCKQUOTE>
046     * This class represents a data structure with information about a notification
047     * subscription defined in an UnboundID server instance.
048     */
049    @NotMutable()
050    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
051    public final class NotificationSubscriptionDetails
052           implements Serializable
053    {
054      /**
055       * The serial version UID for this serializable class.
056       */
057      private static final long serialVersionUID = 7883889980556267057L;
058    
059    
060    
061      // The encoded details for this notification subscription.
062      private final List<ASN1OctetString> details;
063    
064      // The unique ID for this notification subscription.
065      private final String id;
066    
067    
068    
069      /**
070       * Creates a new notification subscription details object with the provided
071       * information.
072       *
073       * @param  id       The unique ID for this notification subscription.  It
074       *                  must not be {@code null}.
075       * @param  details  The encoded details for this notification subscription.
076       *                  It must not be {@code null} or empty.
077       */
078      public NotificationSubscriptionDetails(final String id,
079                  final Collection<ASN1OctetString> details)
080      {
081        Validator.ensureNotNull(id);
082        Validator.ensureNotNull(details);
083        Validator.ensureFalse(details.isEmpty());
084    
085        this.id = id;
086        this.details =
087             Collections.unmodifiableList(new ArrayList<ASN1OctetString>(details));
088      }
089    
090    
091    
092      /**
093       * Retrieves the unique ID for this subscription details object.
094       *
095       * @return The unique ID for this subscription details object.
096       */
097      public String getID()
098      {
099        return id;
100      }
101    
102    
103    
104      /**
105       * Retrieves the encoded details for this subscription details object.
106       *
107       * @return  The encoded details for this subscription details object.
108       */
109      public List<ASN1OctetString> getDetails()
110      {
111        return details;
112      }
113    
114    
115    
116      /**
117       * Retrieves a string representation of this notification subscription details
118       * object.
119       *
120       * @return  A string representation of this notification subscription details
121       *          object.
122       */
123      @Override()
124      public String toString()
125      {
126        final StringBuilder buffer = new StringBuilder();
127        toString(buffer);
128        return buffer.toString();
129      }
130    
131    
132    
133      /**
134       * Appends a string representation of this notification subscription details
135       * object to the provided buffer.
136       *
137       * @param  buffer  The buffer to which the information should be appended.
138       */
139      public void toString(final StringBuilder buffer)
140      {
141        buffer.append("NotificationSubscription(id='");
142        buffer.append(id);
143        buffer.append("')");
144      }
145    }