001/* 002 * Copyright 2017-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2017-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.controls; 022 023 024 025import com.unboundid.util.ThreadSafety; 026import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030/** 031 * This enum defines the set of multiple attribute behavior values that may be 032 * used in conjunction with the {@link UniquenessRequestControl}. 033 * <BR> 034 * <BLOCKQUOTE> 035 * <B>NOTE:</B> This class, and other classes within the 036 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 037 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 038 * server products. These classes provide support for proprietary 039 * functionality or for external specifications that are not considered stable 040 * or mature enough to be guaranteed to work in an interoperable way with 041 * other types of LDAP servers. 042 * </BLOCKQUOTE> 043 */ 044@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 045public enum UniquenessMultipleAttributeBehavior 046{ 047 /** 048 * Indicates that the server should treat each configured attribute 049 * separately. For each attribute, the server will attempt to identify 050 * conflicts with other entries that have the same value for the same 051 * attribute, but it will not flag cases in which the same value is used in 052 * different attribute types. This behavior is equivalent to including 053 * multiple controls in the request, where each control only references a 054 * single attribute type. 055 */ 056 UNIQUE_WITHIN_EACH_ATTRIBUTE(0), 057 058 059 060 /** 061 * Indicates that the server should flag any case in which any entry has a 062 * conflicting value in any of the configured attribute types, including cases 063 * in which the same value appears in multiple attributes within the same 064 * entry. 065 */ 066 UNIQUE_ACROSS_ALL_ATTRIBUTES_INCLUDING_IN_SAME_ENTRY(1), 067 068 069 070 /** 071 * Indicates that the server should flag any case in which any entry has a 072 * conflicting value in any of the configured attribute types, with the 073 * exception that conflicts will be permitted across different attributes in 074 * the same entry. 075 */ 076 UNIQUE_ACROSS_ALL_ATTRIBUTES_EXCEPT_IN_SAME_ENTRY(2), 077 078 079 080 /** 081 * Indicates that the server should flag any case in which another entry has 082 * the same combination of values for all of the configured attribute types. 083 * This will only apply to entries that have at least one value for each of 084 * the target attributes. If any of the target attributes has multiple 085 * values, then the server will flag each unique combination of those values. 086 */ 087 UNIQUE_IN_COMBINATION(3); 088 089 090 091 // The integer value for this uniqueness multiple attribute behavior. 092 private final int intValue; 093 094 095 096 /** 097 * Creates a new uniqueness multiple attribute behavior with the provided 098 * integer value. 099 * 100 * @param intValue The integer value for this uniqueness multiple attribute 101 * behavior. 102 */ 103 UniquenessMultipleAttributeBehavior(final int intValue) 104 { 105 this.intValue = intValue; 106 } 107 108 109 110 /** 111 * Retrieves the integer value for this uniqueness multiple attribute 112 * behavior. 113 * 114 * @return The integer value for this uniqueness multiple attribute behavior. 115 */ 116 public int intValue() 117 { 118 return intValue; 119 } 120 121 122 123 /** 124 * Retrieves the uniqueness multiple attribute behavior with the specified 125 * integer value. 126 * 127 * @param intValue The integer value for the uniqueness multiple attribute 128 * behavior to retrieve. 129 * 130 * @return The uniqueness multiple attribute behavior for the provided 131 * integer value, or {@code null} if there is no multiple attribute 132 * behavior with the given integer value. 133 */ 134 public static UniquenessMultipleAttributeBehavior valueOf(final int intValue) 135 { 136 switch (intValue) 137 { 138 case 0: 139 return UNIQUE_WITHIN_EACH_ATTRIBUTE; 140 case 1: 141 return UNIQUE_ACROSS_ALL_ATTRIBUTES_INCLUDING_IN_SAME_ENTRY; 142 case 2: 143 return UNIQUE_ACROSS_ALL_ATTRIBUTES_EXCEPT_IN_SAME_ENTRY; 144 case 3: 145 return UNIQUE_IN_COMBINATION; 146 default: 147 return null; 148 } 149 } 150}