001/* 002 * Copyright 2007-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2007-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2007-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.schema; 037 038 039 040import com.unboundid.util.NotNull; 041import com.unboundid.util.Nullable; 042import com.unboundid.util.StaticUtils; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * This enum defines the set of attribute type usages that are defined in the 050 * LDAP protocol. 051 */ 052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 053public enum AttributeUsage 054{ 055 /** 056 * The "userApplications" attribute usage. 057 */ 058 USER_APPLICATIONS("userApplications", false), 059 060 061 062 /** 063 * The "directoryOperation" attribute usage. 064 */ 065 DIRECTORY_OPERATION("directoryOperation", true), 066 067 068 069 /** 070 * The "distributedOperation" attribute usage. 071 */ 072 DISTRIBUTED_OPERATION("distributedOperation", true), 073 074 075 076 /** 077 * The "dSAOperation" attribute usage. 078 */ 079 DSA_OPERATION("dSAOperation", true); 080 081 082 083 // Indicates whether this is an operational attribute usage. 084 private final boolean isOperational; 085 086 // The name for this object class type. 087 @NotNull private final String name; 088 089 090 091 /** 092 * Creates a new attribute usage with the specified name. 093 * 094 * @param name The name for this attribute usage. 095 * @param isOperational Indicates whether this is an operational attribute 096 * usage. 097 */ 098 AttributeUsage(@NotNull final String name, final boolean isOperational) 099 { 100 this.name = name; 101 this.isOperational = isOperational; 102 } 103 104 105 106 /** 107 * Retrieves the name of this attribute usage. 108 * 109 * @return The name of this attribute usage. 110 */ 111 @NotNull() 112 public String getName() 113 { 114 return name; 115 } 116 117 118 119 /** 120 * Indicates whether this is an operational attribute usage. 121 * 122 * @return {@code true} if this is an operational attribute usage. 123 */ 124 public boolean isOperational() 125 { 126 return isOperational; 127 } 128 129 130 131 /** 132 * Retrieves the attribute usage value with the specified name. 133 * 134 * @param name The name of the attribute usage to retrieve. It must not be 135 * {@code null}. 136 * 137 * @return The attribute usage with the specified name, or {@code null} if 138 * there is no usage with the given name. 139 */ 140 @Nullable() 141 public static AttributeUsage forName(@NotNull final String name) 142 { 143 switch (StaticUtils.toLowerCase(name)) 144 { 145 case "userapplications": 146 case "user-applications": 147 case "user_applications": 148 return USER_APPLICATIONS; 149 case "directoryoperation": 150 case "directory-operation": 151 case "directory_operation": 152 return DIRECTORY_OPERATION; 153 case "distributedoperation": 154 case "distributed-operation": 155 case "distributed_operation": 156 return DISTRIBUTED_OPERATION; 157 case "dsaoperation": 158 case "dsa-operation": 159 case "dsa_operation": 160 return DSA_OPERATION; 161 default: 162 return null; 163 } 164 } 165 166 167 168 /** 169 * Retrieves a string representation of this attribute usage. 170 * 171 * @return A string representation of this attribute usage. 172 */ 173 @Override() 174 @NotNull() 175 public String toString() 176 { 177 return name; 178 } 179}