001/* 002 * Copyright 2007-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2007-2020 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) 2008-2020 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.StaticUtils; 041import com.unboundid.util.ThreadSafety; 042import com.unboundid.util.ThreadSafetyLevel; 043 044 045 046/** 047 * This enum defines the set of attribute type usages that are defined in the 048 * LDAP protocol. 049 */ 050@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 051public enum AttributeUsage 052{ 053 /** 054 * The "userApplications" attribute usage. 055 */ 056 USER_APPLICATIONS("userApplications", false), 057 058 059 060 /** 061 * The "directoryOperation" attribute usage. 062 */ 063 DIRECTORY_OPERATION("directoryOperation", true), 064 065 066 067 /** 068 * The "distributedOperation" attribute usage. 069 */ 070 DISTRIBUTED_OPERATION("distributedOperation", true), 071 072 073 074 /** 075 * The "dSAOperation" attribute usage. 076 */ 077 DSA_OPERATION("dSAOperation", true); 078 079 080 081 // Indicates whether this is an operational attribute usage. 082 private final boolean isOperational; 083 084 // The name for this object class type. 085 private final String name; 086 087 088 089 /** 090 * Creates a new attribute usage with the specified name. 091 * 092 * @param name The name for this attribute usage. 093 * @param isOperational Indicates whether this is an operational attribute 094 * usage. 095 */ 096 AttributeUsage(final String name, final boolean isOperational) 097 { 098 this.name = name; 099 this.isOperational = isOperational; 100 } 101 102 103 104 /** 105 * Retrieves the name of this attribute usage. 106 * 107 * @return The name of this attribute usage. 108 */ 109 public String getName() 110 { 111 return name; 112 } 113 114 115 116 /** 117 * Indicates whether this is an operational attribute usage. 118 * 119 * @return {@code true} if this is an operational attribute usage. 120 */ 121 public boolean isOperational() 122 { 123 return isOperational; 124 } 125 126 127 128 /** 129 * Retrieves the attribute usage value with the specified name. 130 * 131 * @param name The name of the attribute usage to retrieve. It must not be 132 * {@code null}. 133 * 134 * @return The attribute usage with the specified name, or {@code null} if 135 * there is no usage with the given name. 136 */ 137 public static AttributeUsage forName(final String name) 138 { 139 switch (StaticUtils.toLowerCase(name)) 140 { 141 case "userapplications": 142 case "user-applications": 143 case "user_applications": 144 return USER_APPLICATIONS; 145 case "directoryoperation": 146 case "directory-operation": 147 case "directory_operation": 148 return DIRECTORY_OPERATION; 149 case "distributedoperation": 150 case "distributed-operation": 151 case "distributed_operation": 152 return DISTRIBUTED_OPERATION; 153 case "dsaoperation": 154 case "dsa-operation": 155 case "dsa_operation": 156 return DSA_OPERATION; 157 default: 158 return null; 159 } 160 } 161 162 163 164 /** 165 * Retrieves a string representation of this attribute usage. 166 * 167 * @return A string representation of this attribute usage. 168 */ 169 @Override() 170 public String toString() 171 { 172 return name; 173 } 174}