001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2014-2021 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.ds.types;
028
029
030
031import com.unboundid.directory.sdk.common.schema.AttributeType;
032import com.unboundid.util.NotMutable;
033import com.unboundid.util.ThreadSafety;
034import com.unboundid.util.ThreadSafetyLevel;
035
036import java.util.Collections;
037import java.util.HashMap;
038import java.util.HashSet;
039import java.util.Map;
040import java.util.Set;
041
042
043
044/**
045 * This class defines a structure used by a notification manager to specify
046 * information that it wishes to be included in a change notification.
047 */
048@NotMutable()
049@ThreadSafety(level= ThreadSafetyLevel.COMPLETELY_THREADSAFE)
050public final class NotificationProperties
051{
052  private final String              destinationID;
053  private final Map<String,String>  propertyMap;
054  private final Set<AttributeType>  keyAttributes;
055
056
057
058  /**
059   * Create a new instance of this class from the provided information.
060   *
061   * @param destinationID  The notification destination ID.
062   * @param propertyMap    A set of property names and values to be included
063   *                       in the notification. May be {@code null}.
064   * @param keyAttributes  Any additional key attributes to be recorded in the
065   *                       LDAP changelog entry and included in the
066   *                       notification. May be {@code null}.
067   */
068  public NotificationProperties(
069      final String destinationID,
070      final Map<String,String> propertyMap,
071      final Set<AttributeType> keyAttributes
072  )
073  {
074    this.destinationID = destinationID;
075
076    if (propertyMap == null)
077    {
078      this.propertyMap = Collections.emptyMap();
079    }
080    else
081    {
082      this.propertyMap = Collections.unmodifiableMap(
083          new HashMap<String, String>(propertyMap));
084    }
085
086    if (keyAttributes == null)
087    {
088      this.keyAttributes = Collections.emptySet();
089    }
090    else
091    {
092      this.keyAttributes = Collections.unmodifiableSet(
093          new HashSet<AttributeType>(keyAttributes));
094    }
095  }
096
097
098
099  /**
100   * Retrieve the notification destination ID.
101   *
102   * @return  The notification destination ID.
103   */
104  public String getDestinationID()
105  {
106    return destinationID;
107  }
108
109
110
111  /**
112   * Retrieve the set of property names and values to be included in the
113   * notification.
114   *
115   * @return  The set of property names and values to be included in the
116   *          notification. Guaranteed to be non-null.
117   */
118  public Map<String, String> getPropertyMap()
119  {
120    return propertyMap;
121  }
122
123
124
125  /**
126   * Retrieve the additional key attributes to be recorded in the LDAP
127   * changelog entry and included in the notification.
128   *
129   * @return  The additional key attributes to be recorded in the LDAP
130   *          changelog entry and included in the notification.
131   */
132  public Set<AttributeType> getKeyAttributes()
133  {
134    return keyAttributes;
135  }
136}