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