001/* 002 * Copyright 2014-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2018 Ping Identity Corporation 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 */ 021package com.unboundid.ldap.sdk.unboundidds.extensions; 022 023 024 025import java.io.Serializable; 026import java.util.ArrayList; 027import java.util.Collection; 028import java.util.Collections; 029import java.util.Iterator; 030import java.util.List; 031 032import com.unboundid.asn1.ASN1OctetString; 033import com.unboundid.util.NotMutable; 034import com.unboundid.util.ThreadSafety; 035import com.unboundid.util.ThreadSafetyLevel; 036import com.unboundid.util.Validator; 037 038 039 040/** 041 * This class represents a data structure with information about a notification 042 * destination defined in a Ping Identity, UnboundID, or Alcatel-Lucent 8661 043 * server instance. 044 * <BR> 045 * <BLOCKQUOTE> 046 * <B>NOTE:</B> This class, and other classes within the 047 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 048 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 049 * server products. These classes provide support for proprietary 050 * functionality or for external specifications that are not considered stable 051 * or mature enough to be guaranteed to work in an interoperable way with 052 * other types of LDAP servers. 053 * </BLOCKQUOTE> 054 */ 055@NotMutable() 056@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 057public final class NotificationDestinationDetails 058 implements Serializable 059{ 060 /** 061 * The serial version UID for this serializable class. 062 */ 063 private static final long serialVersionUID = -6596207374277234834L; 064 065 066 067 // The encoded details for this notification destination. 068 private final List<ASN1OctetString> details; 069 070 // The subscriptions defined for this notification destination. 071 private final List<NotificationSubscriptionDetails> subscriptions; 072 073 // The unique ID for this notification destination. 074 private final String id; 075 076 077 078 /** 079 * Creates a new notification destination details object with the provided 080 * information. 081 * 082 * @param id The unique ID for this notification destination. It 083 * must not be {@code null}. 084 * @param details The encoded details for this notification 085 * destination. It must not be {@code null} or empty. 086 * @param subscriptions The subscriptions defined for this notification 087 * destination. It may be {@code null} or empty if 088 * there are no subscriptions for this destination. 089 */ 090 public NotificationDestinationDetails(final String id, 091 final Collection<ASN1OctetString> details, 092 final Collection<NotificationSubscriptionDetails> subscriptions) 093 { 094 Validator.ensureNotNull(id); 095 Validator.ensureNotNull(details); 096 Validator.ensureFalse(details.isEmpty()); 097 098 this.id = id; 099 this.details = 100 Collections.unmodifiableList(new ArrayList<ASN1OctetString>(details)); 101 102 if (subscriptions == null) 103 { 104 this.subscriptions = Collections.emptyList(); 105 } 106 else 107 { 108 this.subscriptions = Collections.unmodifiableList( 109 new ArrayList<NotificationSubscriptionDetails>(subscriptions)); 110 } 111 } 112 113 114 115 /** 116 * Retrieves the unique ID for this destination details object. 117 * 118 * @return The unique ID for this destination details object. 119 */ 120 public String getID() 121 { 122 return id; 123 } 124 125 126 127 /** 128 * Retrieves the encoded details for this destination details object. 129 * 130 * @return The encoded details for this destination details object. 131 */ 132 public List<ASN1OctetString> getDetails() 133 { 134 return details; 135 } 136 137 138 139 /** 140 * Retrieves the subscriptions defined for this notification destination, if 141 * any. 142 * 143 * @return The subscriptions defined for this notification destination, or 144 * an empty list if there are no subscriptions for this destination. 145 */ 146 public List<NotificationSubscriptionDetails> getSubscriptions() 147 { 148 return subscriptions; 149 } 150 151 152 153 /** 154 * Retrieves a string representation of this notification subscription details 155 * object. 156 * 157 * @return A string representation of this notification subscription details 158 * object. 159 */ 160 @Override() 161 public String toString() 162 { 163 final StringBuilder buffer = new StringBuilder(); 164 toString(buffer); 165 return buffer.toString(); 166 } 167 168 169 170 /** 171 * Appends a string representation of this notification subscription details 172 * object to the provided buffer. 173 * 174 * @param buffer The buffer to which the information should be appended. 175 */ 176 public void toString(final StringBuilder buffer) 177 { 178 buffer.append("NotificationDestination(id='"); 179 buffer.append(id); 180 buffer.append("', subscriptionIDs={"); 181 182 final Iterator<NotificationSubscriptionDetails> subscriptionIterator = 183 subscriptions.iterator(); 184 while (subscriptionIterator.hasNext()) 185 { 186 buffer.append('\''); 187 buffer.append(subscriptionIterator.next().getID()); 188 buffer.append('\''); 189 190 if (subscriptionIterator.hasNext()) 191 { 192 buffer.append(", "); 193 } 194 } 195 196 buffer.append("})"); 197 } 198}